To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / CollidoscopeApp / include / AudioEngine.h @ 0:02467299402e

History | View | Annotate | Download (2.16 KB)

1 0:02467299402e f
#pragma once
2
3
#include <array>
4
5
#include "cinder/audio/Context.h"
6
#include "cinder/audio/ChannelRouterNode.h"
7
#include "cinder/audio/MonitorNode.h"
8
#include "cinder/audio/FilterNode.h"
9
#include "BufferToWaveRecorderNode.h"
10
#include "PGranularNode.h"
11
#include "RingBufferPack.h"
12
13
#include "Messages.h"
14
#include "Config.h"
15
16
17
class AudioEngine
18
{
19
public:
20
21
    AudioEngine();
22
23
    ~AudioEngine();
24
25
    // no copies
26
    AudioEngine( const AudioEngine &copy ) = delete;
27
    AudioEngine & operator=(const AudioEngine &copy) = delete;
28
29
    void setup( const Config& Config );
30
31
    size_t getSampleRate();
32
33
    void record( size_t index );
34
35
    void loopOn( size_t waveIdx );
36
37
    void loopOff( size_t waveIdx );
38
39
    void noteOn( size_t waveIdx, int note );
40
41
    void noteOff( size_t waveIdx, int note );
42
43
    size_t getRecordWaveAvailable( size_t index );
44
45
    bool readRecordWave( size_t waveIdx, RecordWaveMsg*, size_t count );
46
47
    void setSelectionSize( size_t waveIdx, size_t size );
48
49
    void setSelectionStart( size_t waveIdx, size_t start );
50
51
    void setGrainDurationCoeff( size_t waveIdx, double coeff );
52
53
    void setFilterCutoff( size_t waveIdx, double cutoff );
54
55
    void checkCursorTriggers( size_t waveIdx, std::vector<CursorTriggerMsg>& cursorTriggers );
56
57
    const ci::audio::Buffer& getAudioOutputBuffer( size_t waveIdx ) const;
58
59
60
private:
61
62
    // nodes for mic input
63
    std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mInputRouterNodes;
64
    // nodes for recording audio input into buffer. Also sends chunks information through
65
    // non-blocking queue
66
    std::array< BufferToWaveRecorderNodeRef, NUM_WAVES > mBufferRecorderNodes;
67
    // pgranulars for loop synths
68
    std::array< PGranularNodeRef, NUM_WAVES > mPGranularNodes;
69
70
71
    std::array< ci::audio::ChannelRouterNodeRef, NUM_WAVES > mOutputRouterNodes;
72
    // nodes to get the audio buffer scoped in the oscilloscope
73
    std::array< ci::audio::MonitorNodeRef, NUM_WAVES > mOutputMonitorNodes;
74
    // nodes for lowpass filtering
75
    std::array< cinder::audio::FilterLowPassNodeRef, NUM_WAVES> mLowPassFilterNodes;
76
77
    std::array< std::unique_ptr< RingBufferPack<CursorTriggerMsg> >, NUM_WAVES > mCursorTriggerRingBufferPacks;
78
79
};