aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples
diff options
context:
space:
mode:
Diffstat (limited to 'maximilian_examples')
-rw-r--r--maximilian_examples/21.Recording.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/maximilian_examples/21.Recording.cpp b/maximilian_examples/21.Recording.cpp
new file mode 100644
index 0000000..82e0e68
--- /dev/null
+++ b/maximilian_examples/21.Recording.cpp
@@ -0,0 +1,54 @@
+#include "maximilian.h"
+
+// Here we define a double floating value that will contain our
+// frame of lovely maximilian generated audio
+double out;
+
+// Our oscillator to fill our frame up with my favourite wave
+maxiOsc osc;
+
+// Our ramp to modulate the oscillators
+maxiOsc ramp;
+
+// We declare our recorder object here, which will call it's
+// default constructor.
+maxiRecorder recorder;
+
+void setup() {
+
+ // Call setup here, make sure you do this so the recorder
+ // knows where to write the file. Currently the recorder
+ // will write the wav file to the directory that this file
+ // is in but you can pass any absolute file path in you'd
+ // like to.
+ recorder.setup("hey.wav");
+
+ // This must be called to start the asynchronous thread to
+ // manage the recorder's internal memory
+ recorder.startRecording();
+}
+
+void play(double *output) {
+
+ // A pulse wave!!! Yay
+ out = osc.pulse(90, ramp.phasor(.2));
+
+ // Fill our output buffer
+ output[0]=out;
+ output[1]=out;
+
+ // After we have filled our output array, send the array
+ // and the size of the array (in this case the amount of
+ // channels, but in ofx or juce you might need to do
+ // something like channels*bufferSize).
+ recorder.passData(output, maxiSettings::channels);
+}
+
+// We don't need to worry about telling the recorder to stop;
+// when the stack unwinds and the maximillian program stops,
+// the recorder will have its destructor called and the wav
+// will be written for you. If you would like to do something
+// more dynamic, look at the class definition in maximilian.h -
+// the api allows for stricter control of the object.
+
+