Chris@305: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@305: Chris@305: /* Chris@305: Sonic Visualiser Chris@305: An audio file viewer and annotation editor. Chris@305: Centre for Digital Music, Queen Mary, University of London. Chris@305: This file copyright 2006 Chris Cannam, 2006-2014 QMUL. Chris@305: Chris@305: This program is free software; you can redistribute it and/or Chris@305: modify it under the terms of the GNU General Public License as Chris@305: published by the Free Software Foundation; either version 2 of the Chris@305: License, or (at your option) any later version. See the file Chris@305: COPYING included with this distribution for more information. Chris@305: */ Chris@305: Chris@305: #ifndef _CLIP_MIXER_H_ Chris@305: #define _CLIP_MIXER_H_ Chris@305: Chris@305: #include Chris@305: #include Chris@305: Chris@305: /** Chris@305: * Mix in synthetic notes produced by resampling a prerecorded Chris@305: * clip. That is, this is a sampler. Chris@305: */ Chris@305: Chris@305: class ClipMixer Chris@305: { Chris@305: public: Chris@305: ClipMixer(int channels, int sampleRate, int blockSize); Chris@305: ~ClipMixer(); Chris@305: Chris@305: bool loadClipData(QString clipFilePath, float clipF0); Chris@305: Chris@305: //!!! what can we find in common with the NoteData type and Chris@305: //!!! AudioGenerator's NoteOff? Chris@305: Chris@305: struct NoteStart { Chris@305: int id; // unique to match note end Chris@305: int frameOffset; // in current processing block Chris@305: float frequency; // Hz Chris@305: float level; // volume in range (0,1] Chris@305: float pan; // range [-1,1] Chris@305: }; Chris@305: Chris@305: struct NoteEnd { Chris@305: int id; // matching note start Chris@305: int frameOffset; // in current processing block Chris@305: }; Chris@305: Chris@305: void mix(float **toBuffers, Chris@305: std::vector newNotes, Chris@305: std::vector endingNotes); Chris@305: Chris@305: private: Chris@305: int m_channels; Chris@305: int m_sampleRate; Chris@305: int m_blockSize; Chris@305: Chris@305: QString m_clipPath; Chris@305: Chris@305: float *m_clipData; Chris@305: int m_clipLength; Chris@305: float m_clipF0; Chris@305: float m_clipRate; Chris@305: }; Chris@305: Chris@305: Chris@305: #endif