admsyn / ofxAudioUnit

An openFrameworks addon which makes it easy to work with Audio Units on OSX and iOS
MIT License
120 stars 24 forks source link

getIsPlaying method inside ofxAudioUnitFilePlayer #18

Open dferrandizmont opened 10 years ago

dferrandizmont commented 10 years ago

Hi admsyn, I'm wondering if there is any option inside ofxAudioUnit to get if the sound we are playing is playing or not like the method inside ofSoundPlayer.

Thank you so much.

admsyn commented 10 years ago

Hey @dferrandizmont , are you talking about the ofxAudioUnitFilePlayer? (EDIT: changed the title)

dferrandizmont commented 10 years ago

Yes, i'm talking about ofxAudioUnitFilePlayer. And I have another question, if I would like to use a reverb parameter for iOS how should I do it?.

Thanks admsyn.

admsyn commented 10 years ago

For reverb, you'd just put a reverb audio unit after your file player. You can check out the params example to see how to find / change parameters on the fly.

The reverb unit has the description kAudioUnitType_Effect kAudioUnitSubType_Reverb2, so:

// in your ofApp class
ofxAudioUnit reverb;

// in your setup()
reverb = ofxAudioUnit(kAudioUnitType_Effect, kAudioUnitSubType_Reverb2);
filePlayer.connectTo(reverb).connectTo(output);
dferrandizmont commented 10 years ago

@admsyn thanks! So, now I would like to edit the reverb I have to do something like this:

float newSpeed = ofMap(x, 0, ofGetWidth(), 0.01, 2, true);

AudioUnitSetParameter(reverb.getUnit(),
                      kVarispeedParam_PlaybackRate,
                      kAudioUnitScope_Global,
                      0,
                      newSpeed,
                      0);

I have to change the line kVarispeedParam_PlaybackRate but I don't know what I have to write here, maybe kReverbParam_DryWetMix ?.

Thank you.

admsyn commented 10 years ago

Yepp, except the params for the reverb2 unit all start with "kReverb2Param_", so if you type that you'll see the list in your autocomplete.

dferrandizmont commented 10 years ago

Ohh thank you so much but now I have another problem, I would like to edit the reverb parameter and now I have this code

float newReverb = ofMap(touch.x, 0, ofGetWidth(), 0, 100, true);

AudioUnitSetParameter(reverb.getUnit(),
                      kReverb2Param_DryWetMix,
                      kAudioUnitScope_Global,
                      0,
                      newReverb,
                      0)

and the reverb always sounds like if its fix to 100%. How can I change it? this is not the right way to do it?, and I saw that the reverb starts default at 100% and I would like to start the reverb at 0% and when I move the finger along the screen it change.

admsyn commented 10 years ago

It's probably expecting a number between 0 and 1 (where 1 is 100%)

dferrandizmont commented 10 years ago

I tried to change the value from 100 to 1 and I have the same problem ..

admsyn commented 10 years ago

Is AudioUnitSetParameter returning an error? Also, can you move this over to the forum or start a new issue for reverb on ios? This is getting a little off topic :)

dferrandizmont commented 10 years ago

No, AudioUnitSetParameter is not returning any error. Okey, i'm going to create a new issue just for that, and about my early question about a method like getIsPlaying?. Thanks adam.