admsyn / ofxAudioUnit

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

Reverb on iOS #19

Closed dferrandizmont closed 9 years ago

dferrandizmont commented 10 years ago

Hi, i'm trying to use a reverb effect on iOS and I can't. My problem is that I can't set the kReverb2Param_DryWetMix to 0 (default is 100%) and when the sound starts it starts with reverb, and my second problem is that if I write

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

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

the kReverb2Param_DryWetMix doesn't change it value and I don't know why.

Thanks.

admsyn commented 10 years ago

Can you post a bit more of your code, like the relevant stuff in setup() or update()?

dferrandizmont commented 10 years ago

Of course, here is the whole code:

.h 

    ofxAudioUnit reverb;
       ofxAudioUnitFilePlayer player;
    ofxAudioUnitOutput output;

.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

    reverb = ofxAudioUnit(kAudioUnitType_Effect, kAudioUnitSubType_Reverb2);
    player.connectTo(reverb).connectTo(output);
    output.start();
    player.setFile(ofFilePath::getAbsolutePath("chopin.mp3"));
    player.loop();
}

//--------------------------------------------------------------
void ofApp::update(){}
//--------------------------------------------------------------
void ofApp::draw(){}
//--------------------------------------------------------------
void ofApp::exit(){}
//--------------------------------------------------------------
void ofApp::touchDown(ofTouchEventArgs & touch){}
//--------------------------------------------------------------
void ofApp::touchMoved(ofTouchEventArgs & touch){

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

    AudioUnitSetParameter(reverb.getUnit(),
                          kReverb2Param_DryWetMix,
                          kAudioUnitScope_Global,
                          0,
                          newReverb,
                          0);
}
//--------------------------------------------------------------
void ofApp::touchUp(ofTouchEventArgs & touch){}
//--------------------------------------------------------------
void ofApp::touchDoubleTap(ofTouchEventArgs & touch){}
//--------------------------------------------------------------
void ofApp::touchCancelled(ofTouchEventArgs & touch){}
//--------------------------------------------------------------
void ofApp::lostFocus(){}
//--------------------------------------------------------------
void ofApp::gotFocus(){}
//--------------------------------------------------------------
void ofApp::gotMemoryWarning(){}
//--------------------------------------------------------------
void ofApp::deviceOrientationChanged(int newOrientation){}

Thank you. 
admsyn commented 9 years ago

Going to close this, but thanks for the report! Managing the parameters for iOS-specific units is out of the scope of the addon I feel.