views:

409

answers:

4

I'm working with midi using the Java sound API. Basically I'm trying to achieve a portamento effect where I can slide between different notes. The closest I've gotten is using the setPitchBend() method in MidiChannel. However, this only allows a range of 2 semitones from the note I started with. Is there another way to achieve this portamento effect, or maybe changing the pitch bend range?

If there's a way to accomplish this in JFugue, that would be acceptable as well.

A: 

Just a guess - can you play out two notes of consecutive pitches, and fade one in as you fade the other one out?

Martin
I tried that technique, and have been testing with different values but it's just not the same. The two notes are too far apart. In order to properly simulate the gradual change of a pitch bend, microtonal notes are needed, which the Java sound API does not support.
Peter
A: 

This may be way out of date - it's nearly two decades since I gave up on MIDI and switched to fretless bass - but for longer slides you used to have to play one note, bend its pitch up to half-way to the next note, then play the next note note bent half way down, so they meet at the same pitch, then repeat the process.

Pete Kirkham
A: 

JFugue supports microtones. (It does it through the JavaSound API, combined with a lot of math)

Whether it can do exactly what you're looking for is another question. I believe the problem you'll run into is that each new note you play will sounds like a new note, as opposed to a bunch of notes tied together. This would be particularly noticeable when a note has an attack and decay value other than 0, or if the instrument has inherently different sounds at the start and end of a note.

In JFugue, you can set the attack and decay of a note by adding 'a' and 'd', followed by values from 0-128, after the note: C5wa0d0 - C-note, 5th octave, whole duration, attack=0, decay=0.

The microtone helper, as currently written, allows you to define a single frequency to a string; for example, you can map 400 to "A400". Then to use this, you would say player.play("[A400]w") (note the brackets).

One way to get what you're looking for is to define frequencies and strings for however many microtones you want, then create a Pattern using a for loop... Pattern p = new Pattern("[A400]wa0d0 [A410]wa0d0 [A420]wa0d0"...); You can probably use a step greater than 1 Hertz for each note, because our ears can't distinguish such slight frequency differences.

If only there were a more elegant solution! But see if that helps.

David
Thanks, that sounds like the right way to do it. However, for some reason it seems that attack velocity is synonymous with volume. a0 is not audible at all, a5 is barely audible, and so on. I tried with several different continuous instruments (trombone, viola, etc.) and the results are the same
Peter
It's different from volume, but I think I see what's happening here - saying attack=0, decay=0 isn't giving the instrument enough time to reach max volume to play the note. Try it without the a/d and use shorter durations (like 64th notes - 's' in JFugue) and see if that helps.
David
A: 

MIDI has a portamento control for pitch slides. Try calling controlChange(65,127) to turn on the portametno control then playing the two notes. controlChange(5, xxx) should change the speed of the pitch slide. controlChange(65,0) will turn portamento off.

Geoff Reedy