| 14 | using namespace gam; |
| 15 | |
| 16 | class MyApp : public AudioApp{ |
| 17 | public: |
| 18 | |
| 19 | SamplePlayer<> player1, player2; |
| 20 | |
| 21 | MyApp(){ |
| 22 | // Load sound file (only once!) into buffer |
| 23 | player1.load("../../sounds/water3.wav"); |
| 24 | |
| 25 | // Assign player1's buffer to player2; |
| 26 | // this can be called safely in the audio thread. |
| 27 | player2.buffer(player1); |
| 28 | |
| 29 | // Make second playback rate slightly higher to create "phasing" |
| 30 | player2.rate(1.005); |
| 31 | } |
| 32 | |
| 33 | void onAudio(AudioIOData& io){ |
| 34 | while(io()){ |
| 35 | float s = (player1() + player2()) * 0.5; |
| 36 | player1.loop(); |
| 37 | player2.loop(); |
| 38 | io.out(0) = io.out(1) = s; |
| 39 | } |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | int main(){ |
| 44 | MyApp().start(); |