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 @ 4:ab6db404403a
History | View | Annotate | Download (2.75 KB)
| 1 |
#pragma once
|
|---|---|
| 2 |
|
| 3 |
#include <string> |
| 4 |
#include <array> |
| 5 |
#include "cinder/Color.h" |
| 6 |
#include "cinder/Xml.h" |
| 7 |
|
| 8 |
|
| 9 |
/**
|
| 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 |
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 |
return mAudioInputDeviceKey;
|
| 31 |
} |
| 32 |
|
| 33 |
/**
|
| 34 |
* Returns number of chunks in a wave
|
| 35 |
*/
|
| 36 |
std::size_t getNumChunks() const
|
| 37 |
{
|
| 38 |
return mNumChunks;
|
| 39 |
} |
| 40 |
|
| 41 |
/** returns wave lenght in seconds */
|
| 42 |
double getWaveLen() const |
| 43 |
{
|
| 44 |
return mWaveLen;
|
| 45 |
} |
| 46 |
|
| 47 |
/**
|
| 48 |
* Returns wave's selection color
|
| 49 |
*/
|
| 50 |
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 |
/**
|
| 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 |
std::size_t getCursorTriggerMessageBufSize() const
|
| 64 |
{
|
| 65 |
return 512; |
| 66 |
} |
| 67 |
|
| 68 |
/** returns the index of the wave associated to the MIDI channel passed as argument */
|
| 69 |
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 |
/**
|
| 95 |
* Returns the maximum size of a wave selection in number of chunks.
|
| 96 |
*/
|
| 97 |
size_t getMaxSelectionNumChunks() const
|
| 98 |
{
|
| 99 |
return 37; |
| 100 |
} |
| 101 |
|
| 102 |
/**
|
| 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 |
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 |
}; |