annotate CollidoscopeApp/include/Config.h @ 18:f1ff1a81be20 tip

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