annotate CollidoscopeApp/include/AudioEngine.h @ 2:dd889fff8423

added some comments
author Fiore Martin <f.martin@qmul.ac.uk>
date Mon, 11 Jul 2016 17:03:40 +0200
parents 02467299402e
children 75b744078d66
rev   line source
f@0 1 #pragma once
f@0 2
f@0 3 #include <array>
f@0 4
f@0 5 #include "cinder/audio/Context.h"
f@0 6 #include "cinder/audio/ChannelRouterNode.h"
f@0 7 #include "cinder/audio/MonitorNode.h"
f@0 8 #include "cinder/audio/FilterNode.h"
f@0 9 #include "BufferToWaveRecorderNode.h"
f@0 10 #include "PGranularNode.h"
f@0 11 #include "RingBufferPack.h"
f@0 12
f@0 13 #include "Messages.h"
f@0 14 #include "Config.h"
f@0 15
f@0 16
f@2 17 /**
f@2 18 * Audio engine of the application. It uses the Cinder library to process audio in input and output.
f@2 19 * The audio engine manages both waves. All methods have a waveIndx parameter to address a specific wave.
f@2 20 */
f@0 21 class AudioEngine
f@0 22 {
f@0 23 public:
f@0 24
f@0 25 AudioEngine();
f@0 26
f@0 27 ~AudioEngine();
f@0 28
f@0 29 // no copies
f@0 30 AudioEngine( const AudioEngine &copy ) = delete;
f@0 31 AudioEngine & operator=(const AudioEngine &copy) = delete;
f@0 32
f@2 33 /**
f@2 34 * Set up of the audio engine.
f@2 35 */
f@0 36 void setup( const Config& Config );
f@0 37
f@0 38 size_t getSampleRate();
f@0 39
f@0 40 void record( size_t index );
f@0 41
f@0 42 void loopOn( size_t waveIdx );
f@0 43
f@0 44 void loopOff( size_t waveIdx );
f@0 45
f@0 46 void noteOn( size_t waveIdx, int note );
f@0 47
f@0 48 void noteOff( size_t waveIdx, int note );
f@0 49
f@2 50 /**
f@2 51 * Returns the number of elements available to read in the wave ring buffer.
f@2 52 * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread,
f@2 53 * when a new wave is recorded.
f@2 54 */
f@0 55 size_t getRecordWaveAvailable( size_t index );
f@2 56 /**
f@2 57 * Called from the graphic thread. Reads count elements from the wave ring buffer into \a buffer.
f@2 58 * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread,
f@2 59 * when a new wave is recorded.
f@2 60 *
f@2 61 */
f@2 62 bool readRecordWave( size_t waveIdx, RecordWaveMsg* buffer, size_t count );
f@0 63
f@0 64 void setSelectionSize( size_t waveIdx, size_t size );
f@0 65
f@0 66 void setSelectionStart( size_t waveIdx, size_t start );
f@0 67
f@0 68 void setGrainDurationCoeff( size_t waveIdx, double coeff );
f@0 69
f@0 70 void setFilterCutoff( size_t waveIdx, double cutoff );
f@0 71
f@0 72 void checkCursorTriggers( size_t waveIdx, std::vector<CursorTriggerMsg>& cursorTriggers );
f@0 73
f@2 74 /**
f@2 75 * Returns a const reference to the audio output buffer. This is the buffer that is sent off to the audio interface at each audio cycle.
f@2 76 * It is used in the graphic thread to draw the oscilloscope.
f@2 77 */
f@0 78 const ci::audio::Buffer& getAudioOutputBuffer( size_t waveIdx ) const;
f@0 79
f@0 80
f@0 81 private:
f@0 82
f@0 83 // nodes for mic input
f@0 84 std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mInputRouterNodes;
f@0 85 // nodes for recording audio input into buffer. Also sends chunks information through
f@0 86 // non-blocking queue
f@0 87 std::array< BufferToWaveRecorderNodeRef, NUM_WAVES > mBufferRecorderNodes;
f@0 88 // pgranulars for loop synths
f@0 89 std::array< PGranularNodeRef, NUM_WAVES > mPGranularNodes;
f@0 90
f@0 91
f@0 92 std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mOutputRouterNodes;
f@0 93 // nodes to get the audio buffer scoped in the oscilloscope
f@0 94 std::array< ci::audio::MonitorNodeRef, NUM_WAVES > mOutputMonitorNodes;
f@0 95 // nodes for lowpass filtering
f@0 96 std::array< cinder::audio::FilterLowPassNodeRef, NUM_WAVES> mLowPassFilterNodes;
f@0 97
f@0 98 std::array< std::unique_ptr< RingBufferPack<CursorTriggerMsg> >, NUM_WAVES > mCursorTriggerRingBufferPacks;
f@0 99
f@2 100 };