Chris@476: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@476: Chris@476: /* Chris@476: Sonic Visualiser Chris@476: An audio file viewer and annotation editor. Chris@476: Centre for Digital Music, Queen Mary, University of London. Chris@476: Chris@476: This program is free software; you can redistribute it and/or Chris@476: modify it under the terms of the GNU General Public License as Chris@476: published by the Free Software Foundation; either version 2 of the Chris@476: License, or (at your option) any later version. See the file Chris@476: COPYING included with this distribution for more information. Chris@476: */ Chris@476: Chris@574: #ifndef SV_AUDIO_CALLBACK_RECORD_TARGET_H Chris@574: #define SV_AUDIO_CALLBACK_RECORD_TARGET_H Chris@574: Chris@574: #include "base/AudioRecordTarget.h" Chris@476: Chris@476: #include Chris@476: Chris@476: #include Chris@575: #include Chris@476: Chris@476: #include Chris@476: #include Chris@476: Chris@476: #include "base/BaseTypes.h" Chris@575: #include "base/RingBuffer.h" Chris@476: Chris@476: class ViewManagerBase; Chris@477: class WritableWaveFileModel; Chris@476: Chris@574: class AudioCallbackRecordTarget : public QObject, Chris@574: public AudioRecordTarget, Chris@574: public breakfastquay::ApplicationRecordTarget Chris@476: { Chris@476: Q_OBJECT Chris@476: Chris@476: public: Chris@574: AudioCallbackRecordTarget(ViewManagerBase *, QString clientName); Chris@574: virtual ~AudioCallbackRecordTarget(); Chris@476: Chris@559: virtual std::string getClientName() const override { return m_clientName; } Chris@476: Chris@559: virtual int getApplicationSampleRate() const override; Chris@559: virtual int getApplicationChannelCount() const override; Chris@476: Chris@559: virtual void setSystemRecordBlockSize(int) override; Chris@559: virtual void setSystemRecordSampleRate(int) override; Chris@559: virtual void setSystemRecordLatency(int) override; Chris@559: virtual void setSystemRecordChannelCount(int) override; Chris@476: Chris@559: virtual void putSamples(const float *const *samples, int nchannels, int nframes) override; Chris@476: Chris@559: virtual void setInputLevels(float peakLeft, float peakRight) override; Chris@476: Chris@559: virtual void audioProcessingOverload() override { } Chris@476: Chris@508: QString getRecordContainerFolder(); Chris@483: QString getRecordFolder(); Chris@483: Chris@574: virtual bool isRecording() const override { return m_recording; } Chris@574: virtual sv_frame_t getRecordDuration() const override { return m_frameCount; } Chris@574: Chris@574: virtual bool getInputLevels(float &left, float &right) override; Chris@574: Chris@574: WritableWaveFileModel *startRecording(); // caller takes ownership of model Chris@476: void stopRecording(); Chris@477: Chris@477: signals: Chris@477: void recordStatusChanged(bool recording); Chris@485: void recordDurationChanged(sv_frame_t, sv_samplerate_t); // emitted occasionally Chris@497: void recordCompleted(); Chris@477: Chris@477: protected slots: Chris@477: void modelAboutToBeDeleted(); Chris@575: void updateModel(); Chris@476: Chris@476: private: Chris@476: ViewManagerBase *m_viewManager; Chris@476: std::string m_clientName; Chris@575: std::atomic_bool m_recording; Chris@476: sv_samplerate_t m_recordSampleRate; Chris@546: int m_recordChannelCount; Chris@485: sv_frame_t m_frameCount; Chris@476: QString m_audioFileName; Chris@477: WritableWaveFileModel *m_model; Chris@575: RingBuffer **m_buffers; Chris@575: QMutex m_bufPtrMutex; Chris@575: int m_bufferCount; Chris@574: float m_inputLeft; Chris@574: float m_inputRight; Chris@575: Chris@575: void recreateBuffers(); Chris@476: }; Chris@476: Chris@476: #endif