Mercurial > hg > opencollidoscope
view 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 |
line wrap: on
line source
#pragma once #include <array> #include "cinder/audio/Context.h" #include "cinder/audio/ChannelRouterNode.h" #include "cinder/audio/MonitorNode.h" #include "cinder/audio/FilterNode.h" #include "BufferToWaveRecorderNode.h" #include "PGranularNode.h" #include "RingBufferPack.h" #include "Messages.h" #include "Config.h" /** * Audio engine of the application. It uses the Cinder library to process audio in input and output. * The audio engine manages both waves. All methods have a waveIndx parameter to address a specific wave. */ class AudioEngine { public: AudioEngine(); ~AudioEngine(); // no copies AudioEngine( const AudioEngine © ) = delete; AudioEngine & operator=(const AudioEngine ©) = delete; /** * Set up of the audio engine. */ void setup( const Config& Config ); size_t getSampleRate(); void record( size_t index ); void loopOn( size_t waveIdx ); void loopOff( size_t waveIdx ); void noteOn( size_t waveIdx, int note ); void noteOff( size_t waveIdx, int note ); /** * Returns the number of elements available to read in the wave ring buffer. * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread, * when a new wave is recorded. */ size_t getRecordWaveAvailable( size_t index ); /** * Called from the graphic thread. Reads count elements from the wave ring buffer into \a buffer. * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread, * when a new wave is recorded. * */ bool readRecordWave( size_t waveIdx, RecordWaveMsg* buffer, size_t count ); void setSelectionSize( size_t waveIdx, size_t size ); void setSelectionStart( size_t waveIdx, size_t start ); void setGrainDurationCoeff( size_t waveIdx, double coeff ); void setFilterCutoff( size_t waveIdx, double cutoff ); void checkCursorTriggers( size_t waveIdx, std::vector<CursorTriggerMsg>& cursorTriggers ); /** * 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. * It is used in the graphic thread to draw the oscilloscope. */ const ci::audio::Buffer& getAudioOutputBuffer( size_t waveIdx ) const; private: // nodes for mic input std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mInputRouterNodes; // nodes for recording audio input into buffer. Also sends chunks information through // non-blocking queue std::array< BufferToWaveRecorderNodeRef, NUM_WAVES > mBufferRecorderNodes; // pgranulars for loop synths std::array< PGranularNodeRef, NUM_WAVES > mPGranularNodes; std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mOutputRouterNodes; // nodes to get the audio buffer scoped in the oscilloscope std::array< ci::audio::MonitorNodeRef, NUM_WAVES > mOutputMonitorNodes; // nodes for lowpass filtering std::array< cinder::audio::FilterLowPassNodeRef, NUM_WAVES> mLowPassFilterNodes; std::array< std::unique_ptr< RingBufferPack<CursorTriggerMsg> >, NUM_WAVES > mCursorTriggerRingBufferPacks; };