annotate CollidoscopeApp/include/Config.h @ 2:dd889fff8423

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