Mercurial > hg > svapp
changeset 475:f93820d36cb0 recording
Start stubbing in audio record
author | Chris Cannam |
---|---|
date | Tue, 18 Aug 2015 14:04:47 +0100 |
parents | fdce8a452b19 |
children | f4d1fa41b94b |
files | audio/AudioCallbackPlaySource.h framework/MainWindowBase.cpp framework/MainWindowBase.h svapp.pro |
diffstat | 4 files changed, 66 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.h Wed Aug 05 17:47:12 2015 +0100 +++ b/audio/AudioCallbackPlaySource.h Tue Aug 18 14:04:47 2015 +0100 @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _AUDIO_CALLBACK_PLAY_SOURCE_H_ -#define _AUDIO_CALLBACK_PLAY_SOURCE_H_ +#ifndef AUDIO_CALLBACK_PLAY_SOURCE_H +#define AUDIO_CALLBACK_PLAY_SOURCE_H #include "base/RingBuffer.h" #include "base/AudioPlaySource.h"
--- a/framework/MainWindowBase.cpp Wed Aug 05 17:47:12 2015 +0100 +++ b/framework/MainWindowBase.cpp Tue Aug 18 14:04:47 2015 +0100 @@ -16,7 +16,6 @@ #include "MainWindowBase.h" #include "Document.h" - #include "view/Pane.h" #include "view/PaneStack.h" #include "data/model/WaveFileModel.h" @@ -48,7 +47,9 @@ #include "widgets/InteractiveFileFinder.h" #include "audio/AudioCallbackPlaySource.h" +#include "audio/AudioRecordTarget.h" #include "audio/PlaySpeedRangeMapper.h" + #include "data/fileio/DataFileReaderFactory.h" #include "data/fileio/PlaylistFileReader.h" #include "data/fileio/WavFileWriter.h" @@ -74,6 +75,7 @@ #include "data/midi/MIDIInput.h" #include <bqaudioio/SystemPlaybackTarget.h> +#include <bqaudioio/SystemAudioIO.h> #include <bqaudioio/AudioFactory.h> #include <QApplication> @@ -132,15 +134,16 @@ #undef Window #endif -MainWindowBase::MainWindowBase(bool withAudioOutput, - bool withMIDIInput) : +MainWindowBase::MainWindowBase(SoundOptions options) : m_document(0), m_paneStack(0), m_viewManager(0), m_timeRulerLayer(0), - m_audioOutput(withAudioOutput), + m_soundOptions(options), m_playSource(0), + m_recordTarget(0), m_playTarget(0), + m_audioIO(0), m_oscQueue(0), m_oscQueueStarter(0), m_midiInput(0), @@ -158,6 +161,12 @@ { Profiler profiler("MainWindowBase::MainWindowBase"); + if (options & WithAudioInput) { + if (!(options & WithAudioOutput)) { + cerr << "WARNING: MainWindowBase: WithAudioInput requires WithAudioOutput -- recording will not work" << endl; + } + } + qRegisterMetaType<sv_frame_t>("sv_frame_t"); qRegisterMetaType<sv_samplerate_t>("sv_samplerate_t"); @@ -219,6 +228,10 @@ m_playSource = new AudioCallbackPlaySource(m_viewManager, QApplication::applicationName()); + if (m_soundOptions & WithAudioInput) { + m_recordTarget = new AudioRecordTarget(m_viewManager, + QApplication::applicationName()); + } connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); @@ -259,7 +272,7 @@ m_labeller = new Labeller(labellerType); m_labeller->setCounterCycleSize(cycle); - if (withMIDIInput) { + if (m_soundOptions & WithMIDIInput) { m_midiInput = new MIDIInput(QApplication::applicationName(), this); } @@ -271,6 +284,8 @@ SVDEBUG << "MainWindowBase::~MainWindowBase" << endl; delete m_playTarget; delete m_playSource; + delete m_audioIO; + delete m_recordTarget; delete m_viewManager; delete m_oscQueue; delete m_oscQueueStarter; @@ -552,7 +567,9 @@ bool haveMainModel = (getMainModel() != 0); bool havePlayTarget = - (m_playTarget != 0); + (m_playTarget != 0 || m_audioIO != 0); + bool haveRecordSource = + (m_audioIO != 0); bool haveSelection = (m_viewManager && !m_viewManager->getSelections().empty()); @@ -597,6 +614,7 @@ emit canMeasureLayer(haveCurrentLayer); emit canSelect(haveMainModel && haveCurrentPane); emit canPlay(haveMainModel && havePlayTarget); + emit canRecord(haveRecordSource); emit canFfwd(haveMainModel); emit canRewind(haveMainModel); emit canPaste(haveClipboardContents); @@ -2160,9 +2178,11 @@ } void -MainWindowBase::createPlayTarget() +MainWindowBase::createAudioIO() { - if (m_playTarget) return; + if (m_playTarget || m_audioIO) return; + + if (!(m_soundOptions & WithAudioOutput)) return; //!!! how to handle preferences /* @@ -2174,13 +2194,18 @@ factory->setDefaultCallbackTarget(targetName); */ - - m_playTarget = - breakfastquay::AudioFactory::createCallbackPlayTarget(m_playSource); - - m_playSource->setSystemPlaybackTarget(m_playTarget); - - if (!m_playTarget) { + + if (m_soundOptions & WithAudioInput) { + m_audioIO = breakfastquay::AudioFactory:: + createCallbackIO(m_recordTarget, m_playSource); + m_playSource->setSystemPlaybackTarget(m_audioIO); + } else { + m_playTarget = breakfastquay::AudioFactory:: + createCallbackPlayTarget(m_playSource); + m_playSource->setSystemPlaybackTarget(m_playTarget); + } + + if (!m_playTarget && !m_audioIO) { emit hideSplash(); // if (factory->isAutoCallbackTarget(targetName)) { @@ -2197,6 +2222,7 @@ QMessageBox::Ok); } */ + return; } } @@ -3334,8 +3360,9 @@ // SVDEBUG << "MainWindowBase::mainModelChanged(" << model << ")" << endl; updateDescriptionLabel(); if (model) m_viewManager->setMainModelSampleRate(model->getSampleRate()); - if (model && !m_playTarget && m_audioOutput) { - createPlayTarget(); + if (model && !(m_playTarget || m_audioIO) && + (m_soundOptions & WithAudioOutput)) { + createAudioIO(); } }
--- a/framework/MainWindowBase.h Wed Aug 05 17:47:12 2015 +0100 +++ b/framework/MainWindowBase.h Tue Aug 18 14:04:47 2015 +0100 @@ -46,6 +46,7 @@ class WaveformLayer; class WaveFileModel; class AudioCallbackPlaySource; +class AudioRecordTarget; class CommandHistory; class QMenu; class AudioDial; @@ -64,6 +65,7 @@ namespace breakfastquay { class SystemPlaybackTarget; +class SystemAudioIO; } /** @@ -80,7 +82,15 @@ Q_OBJECT public: - MainWindowBase(bool withAudioOutput, bool withMIDIInput); + enum SoundOption { + WithAudioOutput = 0x01, + WithAudioInput = 0x02, + WithMIDIInput = 0x04, + WithEverything = 0xff + }; + typedef int SoundOptions; + + MainWindowBase(SoundOptions options = WithEverything); virtual ~MainWindowBase(); enum AudioFileOpenMode { @@ -149,6 +159,7 @@ void canZoom(bool); void canScroll(bool); void canPlay(bool); + void canRecord(bool); void canFfwd(bool); void canRewind(bool); void canPlaySelection(bool); @@ -307,9 +318,12 @@ ViewManager *m_viewManager; Layer *m_timeRulerLayer; - bool m_audioOutput; + SoundOptions m_soundOptions; + AudioCallbackPlaySource *m_playSource; - breakfastquay::SystemPlaybackTarget *m_playTarget; + AudioRecordTarget *m_recordTarget; + breakfastquay::SystemPlaybackTarget *m_playTarget; // only one of this... + breakfastquay::SystemAudioIO *m_audioIO; // ... and this exists class OSCQueueStarter : public QThread { @@ -424,7 +438,7 @@ virtual QString getDefaultSessionTemplate() const; virtual void setDefaultSessionTemplate(QString); - virtual void createPlayTarget(); + virtual void createAudioIO(); virtual void openHelpUrl(QString url); virtual void setupMenus() = 0;
--- a/svapp.pro Wed Aug 05 17:47:12 2015 +0100 +++ b/svapp.pro Tue Aug 18 14:04:47 2015 +0100 @@ -41,12 +41,14 @@ MOC_DIR = o HEADERS += audio/AudioCallbackPlaySource.h \ + audio/AudioRecordTarget.h \ audio/AudioGenerator.h \ audio/ClipMixer.h \ audio/ContinuousSynth.h \ audio/PlaySpeedRangeMapper.h SOURCES += audio/AudioCallbackPlaySource.cpp \ + audio/AudioRecordTarget.cpp \ audio/AudioGenerator.cpp \ audio/ClipMixer.cpp \ audio/ContinuousSynth.cpp \