Sunday, October 4, 2015

Is it possible to define Echo without really understanding it?

Today, having finally initialized my Class and having completed the mandatory parts of Project Pitch Perfect, I decided to explore combining the 4 effects to a single function.

I already had the pitch effects in 1, and the speed in another function.

//set Pitch
        let changePitchEffect = AVAudioUnitTimePitch()
        changePitchEffect.pitch = pitch

        audioEngine.attachNode(changePitchEffect)

So my logic was, if this is the way I changed the pitch let me apply it to speed/rate of the AUdio as well :
//set Rate
        let changeRateEffect = AVAudioUnitVarispeed()
        changeRateEffect.rate = rate
        audioEngine.attachNode(changeRateEffect)

Ta daaaa, it worked.

After a research of short(!) time, I found an example on StackOverFlow that connects multiple effects and applied it to my code.

Ta daaaa, it worked!

So I decided to be more adventurous and after reading manual for an hour and going through some mindboggling examples in Stackoverflow AND with lots of help from Trial and Error Methodology(!) I got the Reverb working... 

//Setting the reverb effect
        let changeReverbEffect = AVAudioUnitReverb()
        changeReverbEffect.loadFactoryPreset(AVAudioUnitReverbPreset.LargeHall2)
        changeReverbEffect.wetDryMix = reverb
        audioEngine.attachNode(changeReverbEffect)

I did manage to apply Echo as well and got a semi-satisfactory result. I tried to find the length of the recorded audio and set it to those number of seconds to get the perfect echo, but without any success. So I set a 30 value and seems to work fine with normal length recordings... 

So the only thing I have left is adding a Pause button! And this was where I messed up the last time. But this time I made sure I have "commit" pressed :-) :-) 



No comments:

Post a Comment