To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / CollidoscopeApp / include / Config.h @ 2:dd889fff8423
History | View | Annotate | Download (2.75 KB)
| 1 | 0:02467299402e | f | #pragma once
|
|---|---|---|---|
| 2 | |||
| 3 | #include <string> |
||
| 4 | #include <array> |
||
| 5 | #include "cinder/Color.h" |
||
| 6 | #include "cinder/Xml.h" |
||
| 7 | |||
| 8 | |||
| 9 | 2:dd889fff8423 | f | /**
|
| 10 | * Configuration class gathers in one place all the values recided at runtime
|
||
| 11 | *
|
||
| 12 | * Reading the configuration from an XML file is partially implemented but not used at the moment
|
||
| 13 | *
|
||
| 14 | */
|
||
| 15 | 0:02467299402e | f | class Config |
| 16 | {
|
||
| 17 | public:
|
||
| 18 | |||
| 19 | Config(); |
||
| 20 | |||
| 21 | // no copies
|
||
| 22 | Config( const Config © ) = delete;
|
||
| 23 | Config & operator=(const Config ©) = delete;
|
||
| 24 | |||
| 25 | /* load values for internal field from configuration file. Throws ci::Exception */
|
||
| 26 | void loadFromFile( std::string&& path );
|
||
| 27 | |||
| 28 | std::string getInputDeviceKey() const
|
||
| 29 | {
|
||
| 30 | 2:dd889fff8423 | f | return mAudioInputDeviceKey;
|
| 31 | 0:02467299402e | f | } |
| 32 | |||
| 33 | 2:dd889fff8423 | f | /**
|
| 34 | * Returns number of chunks in a wave
|
||
| 35 | */
|
||
| 36 | 0:02467299402e | f | std::size_t getNumChunks() const
|
| 37 | {
|
||
| 38 | return mNumChunks;
|
||
| 39 | } |
||
| 40 | |||
| 41 | 2:dd889fff8423 | f | /** returns wave lenght in seconds */
|
| 42 | 0:02467299402e | f | double getWaveLen() const |
| 43 | {
|
||
| 44 | return mWaveLen;
|
||
| 45 | } |
||
| 46 | |||
| 47 | 2:dd889fff8423 | f | /**
|
| 48 | * Returns wave's selection color
|
||
| 49 | */
|
||
| 50 | 0:02467299402e | f | ci::Color getWaveSelectionColor(size_t waveIdx) const
|
| 51 | {
|
||
| 52 | if (waveIdx == 0){ |
||
| 53 | return cinder::Color(243.0f / 255.0f, 6.0f / 255.0f, 62.0f / 255.0f); |
||
| 54 | } |
||
| 55 | else{
|
||
| 56 | return cinder::Color(255.0f / 255.0f, 204.0f / 255.0f, 0.0f / 255.0f); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | 2:dd889fff8423 | f | /**
|
| 61 | * The size of the ring buffer used to trigger a visual cursor from the audio thread when a new grain is created
|
||
| 62 | */
|
||
| 63 | 0:02467299402e | f | std::size_t getCursorTriggerMessageBufSize() const
|
| 64 | {
|
||
| 65 | return 512; |
||
| 66 | } |
||
| 67 | |||
| 68 | 2:dd889fff8423 | f | /** returns the index of the wave associated to the MIDI channel passed as argument */
|
| 69 | 0:02467299402e | f | size_t getWaveForMIDIChannel( unsigned char channelIdx ) |
| 70 | {
|
||
| 71 | return channelIdx;
|
||
| 72 | } |
||
| 73 | |||
| 74 | double getMaxGrainDurationCoeff() const |
||
| 75 | {
|
||
| 76 | return 8.0; |
||
| 77 | } |
||
| 78 | |||
| 79 | double getMaxFilterCutoffFreq() const |
||
| 80 | {
|
||
| 81 | return 22050.; |
||
| 82 | } |
||
| 83 | |||
| 84 | double getMinFilterCutoffFreq() const |
||
| 85 | {
|
||
| 86 | return 200.; |
||
| 87 | } |
||
| 88 | |||
| 89 | size_t getMaxKeyboardVoices() const
|
||
| 90 | {
|
||
| 91 | return 6; |
||
| 92 | } |
||
| 93 | |||
| 94 | 2:dd889fff8423 | f | /**
|
| 95 | * Returns the maximum size of a wave selection in number of chunks.
|
||
| 96 | */
|
||
| 97 | 0:02467299402e | f | size_t getMaxSelectionNumChunks() const
|
| 98 | {
|
||
| 99 | return 37; |
||
| 100 | } |
||
| 101 | |||
| 102 | 2:dd889fff8423 | f | /**
|
| 103 | * The value returned is used when creating the oscilloscope.
|
||
| 104 | * The oscilloscope represents the audio output buffer graphically. However it doesn't need to be as refined as the
|
||
| 105 | * audio wave and it's downsampled using the following formula : number of oscilloscope points = size o audio output buffer / getOscilloscopeNumPointsDivider()
|
||
| 106 | */
|
||
| 107 | 0:02467299402e | f | size_t getOscilloscopeNumPointsDivider() const
|
| 108 | {
|
||
| 109 | return 4; |
||
| 110 | } |
||
| 111 | |||
| 112 | private:
|
||
| 113 | |||
| 114 | void parseWave( const ci::XmlTree &wave, int id ); |
||
| 115 | |||
| 116 | std::string mAudioInputDeviceKey; |
||
| 117 | std::size_t mNumChunks; |
||
| 118 | double mWaveLen;
|
||
| 119 | std::array< size_t, NUM_WAVES > mMidiChannels; |
||
| 120 | |||
| 121 | }; |