In this example, we show how you can connect and disconnect DSP units. It either applies a sound pitching effect or a band filtering effect. Periodicallty, the DSP that is used is disconnected and the other one takes the place in the chain.
void connexions() { // Init try { OggFileDecoder decoder("track.ogg"); LibaoOutput ao("oss", 0); Flanger flanger; BandFilter filter; } catch (IzSoundException &err) { cout << err.what() << endl; return; } // Connection decoder.connect(&flanger, 0, 0); flanger.connect(&ao, 0, 0); // Let's roll baby ! unsigned int cpt = 0; while (!decoder.isEndReached()) { decoder.run(); if (++cpt % 1500 == 0) { decoder.disconnect(0); flanger.disconnect(0); decoder.connect(&filter, 0, 0); filter.connect(&ao, 0, 0); flanger.reset(); } else if (cpt % 750 == 0) { decoder.disconnect(0); filter.disconnect(0); decoder.connect(&flanger, 0, 0); flanger.connect(&ao, 0, 0); } } for (int i = 0; i < 10; ++i) { decoder.run(); } // Cleanups ao.flush(); }