diff options
Diffstat (limited to 'src/sample.cc')
-rw-r--r-- | src/sample.cc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/sample.cc b/src/sample.cc index 22bee14..ced8a47 100644 --- a/src/sample.cc +++ b/src/sample.cc @@ -26,9 +26,15 @@ */ #include "sample.h" +#include <stdlib.h> +#include <unistd.h> + +#include <sndfile.h> + Sample::Sample(const std::string& name, float power) - : name(name) - , power(power) + : name{name} + , power{power} + , audiofiles{} { } @@ -36,25 +42,24 @@ Sample::~Sample() { } -void Sample::addAudioFile(InstrumentChannel* instrument_channel, - AudioFile* audio_file) +void Sample::addAudioFile(Channel* c, AudioFile* a) { - audiofiles[instrument_channel] = audio_file; + audiofiles[c] = a; } -AudioFile *Sample::getAudioFile(InstrumentChannel* instrument_channel) +AudioFile* Sample::getAudioFile(Channel* c) { /* - if(audiofiles.find(c) == audiofiles.end()) return NULL; - return audiofiles[c]; + if(audiofiles.find(c) == audiofiles.end()) return nullptr; + return audiofiles[c]; */ - for(auto& audio_file : audiofiles) + // todo: std::find_if ?? + for (auto& pair: audiofiles) { - InstrumentChannel *ch = audio_file.first; - if(instrument_channel->num == ch->num) + if (pair.first->num == c->num) { - return audio_file.second; + return pair.second; } } |