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
History | View | Annotate | Download (3.48 KB)
| 1 |
/*
|
|---|---|
| 2 |
|
| 3 |
Copyright (C) 2016 Queen Mary University of London
|
| 4 |
Author: Fiore Martin
|
| 5 |
|
| 6 |
This file is part of Collidoscope.
|
| 7 |
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify
|
| 9 |
it under the terms of the GNU General Public License as published by
|
| 10 |
the Free Software Foundation, either version 3 of the License, or
|
| 11 |
(at your option) any later version.
|
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful,
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
GNU General Public License for more details.
|
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 20 |
*/
|
| 21 |
|
| 22 |
#pragma once
|
| 23 |
|
| 24 |
#include <string> |
| 25 |
#include <array> |
| 26 |
#include "cinder/Color.h" |
| 27 |
#include "cinder/Xml.h" |
| 28 |
|
| 29 |
|
| 30 |
/**
|
| 31 |
* Configuration class gathers in one place all the values recided at runtime
|
| 32 |
*
|
| 33 |
* Reading the configuration from an XML file is partially implemented but not used at the moment
|
| 34 |
*
|
| 35 |
*/
|
| 36 |
class Config |
| 37 |
{
|
| 38 |
public:
|
| 39 |
|
| 40 |
Config(); |
| 41 |
|
| 42 |
// no copies
|
| 43 |
Config( const Config © ) = delete;
|
| 44 |
Config & operator=(const Config ©) = delete;
|
| 45 |
|
| 46 |
/* load values for internal field from configuration file. Throws ci::Exception */
|
| 47 |
void loadFromFile( std::string&& path );
|
| 48 |
|
| 49 |
std::string getInputDeviceKey() const
|
| 50 |
{
|
| 51 |
return mAudioInputDeviceKey;
|
| 52 |
} |
| 53 |
|
| 54 |
/**
|
| 55 |
* Returns number of chunks in a wave
|
| 56 |
*/
|
| 57 |
std::size_t getNumChunks() const
|
| 58 |
{
|
| 59 |
return mNumChunks;
|
| 60 |
} |
| 61 |
|
| 62 |
/** returns wave lenght in seconds */
|
| 63 |
double getWaveLen() const |
| 64 |
{
|
| 65 |
return mWaveLen;
|
| 66 |
} |
| 67 |
|
| 68 |
/**
|
| 69 |
* Returns wave selection color
|
| 70 |
*/
|
| 71 |
ci::Color getWaveSelectionColor(size_t waveIdx) const
|
| 72 |
{
|
| 73 |
if (waveIdx == 0){ |
| 74 |
return cinder::Color(243.0f / 255.0f, 6.0f / 255.0f, 62.0f / 255.0f); |
| 75 |
} |
| 76 |
else{
|
| 77 |
return cinder::Color(255.0f / 255.0f, 204.0f / 255.0f, 0.0f / 255.0f); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
/**
|
| 82 |
* The size of the ring buffer used to trigger a visual cursor from the audio thread when a new grain is created
|
| 83 |
*/
|
| 84 |
std::size_t getCursorTriggerMessageBufSize() const
|
| 85 |
{
|
| 86 |
return 512; |
| 87 |
} |
| 88 |
|
| 89 |
/** returns the index of the wave associated to the MIDI channel passed as argument */
|
| 90 |
size_t getWaveForMIDIChannel( unsigned char channelIdx ) |
| 91 |
{
|
| 92 |
return channelIdx;
|
| 93 |
} |
| 94 |
|
| 95 |
double getMaxGrainDurationCoeff() const |
| 96 |
{
|
| 97 |
return 8.0; |
| 98 |
} |
| 99 |
|
| 100 |
double getMaxFilterCutoffFreq() const |
| 101 |
{
|
| 102 |
return 22050.; |
| 103 |
} |
| 104 |
|
| 105 |
double getMinFilterCutoffFreq() const |
| 106 |
{
|
| 107 |
return 200.; |
| 108 |
} |
| 109 |
|
| 110 |
size_t getMaxKeyboardVoices() const
|
| 111 |
{
|
| 112 |
return 6; |
| 113 |
} |
| 114 |
|
| 115 |
/**
|
| 116 |
* Returns the maximum size of a wave selection in number of chunks.
|
| 117 |
*/
|
| 118 |
size_t getMaxSelectionNumChunks() const
|
| 119 |
{
|
| 120 |
return 37; |
| 121 |
} |
| 122 |
|
| 123 |
/**
|
| 124 |
* The value returned is used when creating the oscilloscope.
|
| 125 |
* The oscilloscope represents the audio output buffer graphically. However it doesn't need to be as refined as the
|
| 126 |
* audio wave and it's downsampled using the following formula : (number of oscilloscope points) = (size of audio output buffer) / getOscilloscopeNumPointsDivider()
|
| 127 |
*/
|
| 128 |
size_t getOscilloscopeNumPointsDivider() const
|
| 129 |
{
|
| 130 |
return 4; |
| 131 |
} |
| 132 |
|
| 133 |
private:
|
| 134 |
|
| 135 |
void parseWave( const ci::XmlTree &wave, int id ); |
| 136 |
|
| 137 |
std::string mAudioInputDeviceKey; |
| 138 |
std::size_t mNumChunks; |
| 139 |
double mWaveLen;
|
| 140 |
std::array< size_t, NUM_WAVES > mMidiChannels; |
| 141 |
|
| 142 |
}; |