views:

86

answers:

2

Hi,

I try to change the frequency of a single soundfile. I managed to do that in android with the SoundPool thing. But the result sounds really bad. So I stepped about the Fourier Transformation - but I am not sure if this is what I am looking for.

I want to load a single file and change the frequency of that file every time that file is played. So I can create melodies out of one tone. Is that possible with android/java?

A: 

The simplest way with the SoundPool is to adjust the rate on your call to play():

play(aSoundId, leftVolume, rightVolume, 1, 0, rate);

The rate can vary from .5f to 2.0f, though the extremes typically don't sound great, so you may want to set an acceptable range (e.g., .4f) and a minimum rate (e.g., .85f). Then you can have a variable to control where you are within that range (e.g., a float that ranges between .0f and 1.0f):

float rate = RATE_RANGE * pitch + MINIMUM_RATE;
Ian G. Clifton
I've had difficulties with using the rate parameter - see http://stackoverflow.com/questions/2291531/android-soundpool-rate-range . Does anyone else encounter this, or have a workaround?
Chris
A: 

This is the way I managed to do it. With "bad" I mean it sounds out of tune.

If I want to play the next frequency of the note in the file I must multiply it by 2^(1/12). But since it's just a float, I guess it's not precise enough to get the "real" frequency of the next note.

Is there a "simple" way to achieve that goal?

gismor