f@5: /*
f@5:
f@5: Copyright (C) 2016 Queen Mary University of London
f@5: Author: Fiore Martin
f@5:
f@5: This file is part of Collidoscope.
f@5:
f@5: Collidoscope is free software: you can redistribute it and/or modify
f@5: it under the terms of the GNU General Public License as published by
f@5: the Free Software Foundation, either version 3 of the License, or
f@5: (at your option) any later version.
f@5:
f@5: This program is distributed in the hope that it will be useful,
f@5: but WITHOUT ANY WARRANTY; without even the implied warranty of
f@5: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f@5: GNU General Public License for more details.
f@5:
f@5: You should have received a copy of the GNU General Public License
f@5: along with this program. If not, see .
f@5: */
f@5:
f@0: #pragma once
f@0:
f@0: #include
f@0: #include
f@0: #include "cinder/Color.h"
f@0: #include "cinder/Xml.h"
f@0:
f@0:
f@2: /**
f@2: * Configuration class gathers in one place all the values recided at runtime
f@2: *
f@2: * Reading the configuration from an XML file is partially implemented but not used at the moment
f@2: *
f@2: */
f@0: class Config
f@0: {
f@0: public:
f@0:
f@0: Config();
f@0:
f@0: // no copies
f@0: Config( const Config © ) = delete;
f@0: Config & operator=(const Config ©) = delete;
f@0:
f@0: /* load values for internal field from configuration file. Throws ci::Exception */
f@0: void loadFromFile( std::string&& path );
f@0:
f@0: std::string getInputDeviceKey() const
f@0: {
f@2: return mAudioInputDeviceKey;
f@0: }
f@0:
f@2: /**
f@2: * Returns number of chunks in a wave
f@2: */
f@0: std::size_t getNumChunks() const
f@0: {
f@0: return mNumChunks;
f@0: }
f@0:
f@2: /** returns wave lenght in seconds */
f@0: double getWaveLen() const
f@0: {
f@0: return mWaveLen;
f@0: }
f@0:
f@2: /**
f@16: * Returns wave selection color
f@2: */
f@0: ci::Color getWaveSelectionColor(size_t waveIdx) const
f@0: {
f@0: if (waveIdx == 0){
f@0: return cinder::Color(243.0f / 255.0f, 6.0f / 255.0f, 62.0f / 255.0f);
f@0: }
f@0: else{
f@0: return cinder::Color(255.0f / 255.0f, 204.0f / 255.0f, 0.0f / 255.0f);
f@0: }
f@0: }
f@0:
f@2: /**
f@2: * The size of the ring buffer used to trigger a visual cursor from the audio thread when a new grain is created
f@2: */
f@0: std::size_t getCursorTriggerMessageBufSize() const
f@0: {
f@0: return 512;
f@0: }
f@0:
f@2: /** returns the index of the wave associated to the MIDI channel passed as argument */
f@0: size_t getWaveForMIDIChannel( unsigned char channelIdx )
f@0: {
f@0: return channelIdx;
f@0: }
f@0:
f@0: double getMaxGrainDurationCoeff() const
f@0: {
f@0: return 8.0;
f@0: }
f@0:
f@0: double getMaxFilterCutoffFreq() const
f@0: {
f@0: return 22050.;
f@0: }
f@0:
f@0: double getMinFilterCutoffFreq() const
f@0: {
f@0: return 200.;
f@0: }
f@0:
f@0: size_t getMaxKeyboardVoices() const
f@0: {
f@0: return 6;
f@0: }
f@0:
f@2: /**
f@2: * Returns the maximum size of a wave selection in number of chunks.
f@2: */
f@0: size_t getMaxSelectionNumChunks() const
f@0: {
f@0: return 37;
f@0: }
f@0:
f@2: /**
f@2: * The value returned is used when creating the oscilloscope.
f@2: * The oscilloscope represents the audio output buffer graphically. However it doesn't need to be as refined as the
f@16: * audio wave and it's downsampled using the following formula : (number of oscilloscope points) = (size of audio output buffer) / getOscilloscopeNumPointsDivider()
f@2: */
f@0: size_t getOscilloscopeNumPointsDivider() const
f@0: {
f@0: return 4;
f@0: }
f@0:
f@0: private:
f@0:
f@0: void parseWave( const ci::XmlTree &wave, int id );
f@0:
f@0: std::string mAudioInputDeviceKey;
f@0: std::size_t mNumChunks;
f@0: double mWaveLen;
f@0: std::array< size_t, NUM_WAVES > mMidiChannels;
f@0:
f@0: };