Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Generating Audio in Android (by playing multiple short audio files concurrently)

$
0
0

Hi Everyone

I would like to generate sounds using Processing for Android. The way I would like to do that is by generating individual pulses and varying the timing between them (Shorter interval = higher pitch).

[I'm using this audio to generate haptic feedback - ultimately planning on running an experiment with it, that's why I need this type of low level control over the audio output - I'm essentially trying to recreate something that I have built in MAX/MSP a while ago]

I was hoping to prerecord an impulse and then play it say, every ~20 milliseconds. I just started tinkering with the cassette library for doing this (https://github.com/shlomihod/cassette) however, I am unable to play the same sound multiple times concurrently:

Lets say my audio file is 1 second long and I try to do this:

     pulse = new SoundFile(this, "impulse.wav");
     pulse.play();
     delay(20);
     pulse.play();

the second pulse does not play (because the first one is still playing)

I need to do this:

    pulse = new SoundFile(this, "impulse.wav");
    pulse1 = new SoundFile(this, "impulse.wav");
    pulse.play();
    delay(20);
    pulse1.play();

now I hear both pulses.

Obviously loading the pulse thousends of times on program start is a clumsy way of doing this. Does anyone have any other suggestions on how to set this up? Please not that I need to be able to set the interval between two pulses individually for each interval.

Is this even feasible?

How would you approach this?


Viewing all articles
Browse latest Browse all 941

Trending Articles