annotate CollidoscopeApp/include/AudioEngine.h @ 18:f1ff1a81be20 tip

Changed licenses names. Fixed one comment and usage text in CollidoscopeApp.cpp.
author Fiore Martin <f.martin@qmul.ac.uk>
date Thu, 25 Aug 2016 12:07:50 +0200
parents 4dad0b810f18
children
rev   line source
f@5 1 /*
f@5 2
f@5 3 Copyright (C) 2016 Queen Mary University of London
f@5 4 Author: Fiore Martin
f@5 5
f@5 6 This file is part of Collidoscope.
f@5 7
f@5 8 Collidoscope is free software: you can redistribute it and/or modify
f@5 9 it under the terms of the GNU General Public License as published by
f@5 10 the Free Software Foundation, either version 3 of the License, or
f@5 11 (at your option) any later version.
f@5 12
f@5 13 This program is distributed in the hope that it will be useful,
f@5 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
f@5 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f@5 16 GNU General Public License for more details.
f@5 17
f@5 18 You should have received a copy of the GNU General Public License
f@5 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
f@5 20 */
f@5 21
f@0 22 #pragma once
f@0 23
f@0 24 #include <array>
f@0 25
f@0 26 #include "cinder/audio/Context.h"
f@0 27 #include "cinder/audio/ChannelRouterNode.h"
f@0 28 #include "cinder/audio/MonitorNode.h"
f@0 29 #include "cinder/audio/FilterNode.h"
f@0 30 #include "BufferToWaveRecorderNode.h"
f@0 31 #include "PGranularNode.h"
f@0 32 #include "RingBufferPack.h"
f@0 33
f@0 34 #include "Messages.h"
f@0 35 #include "Config.h"
f@0 36
f@0 37
f@2 38 /**
f@2 39 * Audio engine of the application. It uses the Cinder library to process audio in input and output.
f@2 40 * The audio engine manages both waves. All methods have a waveIndx parameter to address a specific wave.
f@2 41 */
f@0 42 class AudioEngine
f@0 43 {
f@0 44 public:
f@0 45
f@0 46 AudioEngine();
f@0 47
f@0 48 ~AudioEngine();
f@0 49
f@0 50 // no copies
f@0 51 AudioEngine( const AudioEngine &copy ) = delete;
f@0 52 AudioEngine & operator=(const AudioEngine &copy) = delete;
f@0 53
f@2 54 /**
f@2 55 * Set up of the audio engine.
f@2 56 */
f@0 57 void setup( const Config& Config );
f@0 58
f@0 59 size_t getSampleRate();
f@0 60
f@0 61 void record( size_t index );
f@0 62
f@0 63 void loopOn( size_t waveIdx );
f@0 64
f@0 65 void loopOff( size_t waveIdx );
f@0 66
f@0 67 void noteOn( size_t waveIdx, int note );
f@0 68
f@0 69 void noteOff( size_t waveIdx, int note );
f@0 70
f@2 71 /**
f@2 72 * Returns the number of elements available to read in the wave ring buffer.
f@2 73 * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread,
f@2 74 * when a new wave is recorded.
f@2 75 */
f@0 76 size_t getRecordWaveAvailable( size_t index );
f@2 77 /**
f@16 78 * Called from the graphic thread. Reads \a count elements from the wave ring buffer into \a buffer.
f@2 79 * The wave ring buffer is used to pass the size of the wave chunks from the audio thread to the graphic thread,
f@2 80 * when a new wave is recorded.
f@2 81 *
f@2 82 */
f@2 83 bool readRecordWave( size_t waveIdx, RecordWaveMsg* buffer, size_t count );
f@0 84
f@0 85 void setSelectionSize( size_t waveIdx, size_t size );
f@0 86
f@0 87 void setSelectionStart( size_t waveIdx, size_t start );
f@0 88
f@0 89 void setGrainDurationCoeff( size_t waveIdx, double coeff );
f@0 90
f@0 91 void setFilterCutoff( size_t waveIdx, double cutoff );
f@0 92
f@0 93 void checkCursorTriggers( size_t waveIdx, std::vector<CursorTriggerMsg>& cursorTriggers );
f@0 94
f@2 95 /**
f@2 96 * 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 97 * It is used in the graphic thread to draw the oscilloscope.
f@2 98 */
f@0 99 const ci::audio::Buffer& getAudioOutputBuffer( size_t waveIdx ) const;
f@0 100
f@0 101
f@0 102 private:
f@0 103
f@0 104 // nodes for mic input
f@0 105 std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mInputRouterNodes;
f@0 106 // nodes for recording audio input into buffer. Also sends chunks information through
f@0 107 // non-blocking queue
f@0 108 std::array< BufferToWaveRecorderNodeRef, NUM_WAVES > mBufferRecorderNodes;
f@16 109 // pgranulars wrapped in a Cinder::Node
f@0 110 std::array< PGranularNodeRef, NUM_WAVES > mPGranularNodes;
f@0 111
f@0 112
f@0 113 std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mOutputRouterNodes;
f@0 114 // nodes to get the audio buffer scoped in the oscilloscope
f@0 115 std::array< ci::audio::MonitorNodeRef, NUM_WAVES > mOutputMonitorNodes;
f@0 116 // nodes for lowpass filtering
f@0 117 std::array< cinder::audio::FilterLowPassNodeRef, NUM_WAVES> mLowPassFilterNodes;
f@0 118
f@0 119 std::array< std::unique_ptr< RingBufferPack<CursorTriggerMsg> >, NUM_WAVES > mCursorTriggerRingBufferPacks;
f@0 120
f@2 121 };