Mercurial > hg > svapp
comparison audio/AudioRecordTarget.cpp @ 485:21d3cf5c8f21 tony-2.0-integration
Add status bar "Recording" message and timer while recording
author | Chris Cannam |
---|---|
date | Wed, 16 Sep 2015 12:04:26 +0100 |
parents | 493f2af85497 |
children | 2f5ffd36879b cd9dec2f47e8 |
comparison
equal
deleted
inserted
replaced
484:01aeda073720 | 485:21d3cf5c8f21 |
---|---|
25 QString clientName) : | 25 QString clientName) : |
26 m_viewManager(manager), | 26 m_viewManager(manager), |
27 m_clientName(clientName.toUtf8().data()), | 27 m_clientName(clientName.toUtf8().data()), |
28 m_recording(false), | 28 m_recording(false), |
29 m_recordSampleRate(44100), | 29 m_recordSampleRate(44100), |
30 m_frameCount(0), | |
30 m_model(0) | 31 m_model(0) |
31 { | 32 { |
32 } | 33 } |
33 | 34 |
34 AudioRecordTarget::~AudioRecordTarget() | 35 AudioRecordTarget::~AudioRecordTarget() |
53 } | 54 } |
54 | 55 |
55 void | 56 void |
56 AudioRecordTarget::putSamples(int nframes, float **samples) | 57 AudioRecordTarget::putSamples(int nframes, float **samples) |
57 { | 58 { |
58 QMutexLocker locker(&m_mutex); //!!! bad here | 59 bool secChanged = false; |
59 if (!m_recording) return; | 60 sv_frame_t frameToEmit = 0; |
60 m_model->addSamples(samples, nframes); | 61 |
62 { | |
63 QMutexLocker locker(&m_mutex); //!!! bad here | |
64 if (!m_recording) return; | |
65 | |
66 m_model->addSamples(samples, nframes); | |
67 | |
68 sv_frame_t priorFrameCount = m_frameCount; | |
69 m_frameCount += nframes; | |
70 | |
71 RealTime priorRT = RealTime::frame2RealTime | |
72 (priorFrameCount, m_recordSampleRate); | |
73 RealTime postRT = RealTime::frame2RealTime | |
74 (m_frameCount, m_recordSampleRate); | |
75 | |
76 secChanged = (postRT.sec > priorRT.sec); | |
77 if (secChanged) frameToEmit = m_frameCount; | |
78 } | |
79 | |
80 if (secChanged) { | |
81 emit recordDurationChanged(frameToEmit, m_recordSampleRate); | |
82 } | |
61 } | 83 } |
62 | 84 |
63 void | 85 void |
64 AudioRecordTarget::setInputLevels(float peakLeft, float peakRight) | 86 AudioRecordTarget::setInputLevels(float peakLeft, float peakRight) |
65 { | 87 { |
97 cerr << "WARNING: AudioRecordTarget::startRecording: We are already recording" << endl; | 119 cerr << "WARNING: AudioRecordTarget::startRecording: We are already recording" << endl; |
98 return 0; | 120 return 0; |
99 } | 121 } |
100 | 122 |
101 m_model = 0; | 123 m_model = 0; |
124 m_frameCount = 0; | |
102 | 125 |
103 QString folder = getRecordFolder(); | 126 QString folder = getRecordFolder(); |
104 if (folder == "") return 0; | 127 if (folder == "") return 0; |
105 QDir recordedDir(folder); | 128 QDir recordedDir(folder); |
106 | 129 |