-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.cpp
More file actions
559 lines (471 loc) · 22.6 KB
/
Copy pathaudio.cpp
File metadata and controls
559 lines (471 loc) · 22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
#include "audio.h"
#include <QWidget>
#include <QLabel>
#include "wavform.h"
#include "waveformsegments.h"
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QFileDialog>
#define WAVFORM_HEIGHT 200
#define WAVFORM_WIDTH 400
/*
* File: audio.cpp
* Description:
* This source file implements the 'Audio' class, providing the functionality for audio playback, upload,
* visualization, and control interactions. The class uses 'QMediaPlayer' and 'QAudioOutput' for audio
* playback and integrates waveform and zoom controls. The constructor 'Audio(QWidget *parent)' calls the
* 'newAudioPlayer()' method which sets up the UI, including the upload and play buttons, waveform display,
* and zoom controls, and the audio playback is managed with 'QMediaPlayer' and supports scrubbing and
* zooming functionality.
*
* Key Methods:
* - 'newAudioPlayer()': Sets up the layout, buttons, waveform, and timer connections
* - 'uploadAudio()': Handles the file selection process and media player setup
* - 'handlePlayPause()': Manages the play/pause state of the audio player and updates the timer
* - 'setTrackPosition(qint64 position)': Updates the current track position and emits the
* 'audioPositionChanged' signal
* - 'applySegmentInterval()': Updates waveform segments based on user-defined intervals
*
* Slots:
* - 'updateTrackPositionFromTimer()': Advances the audio position periodically based on the media player position, with elements of smoothing for a better UI
* - 'updateTrackPositionFromScrubber(double position)': Adjusts the player position when the scrubber is moved
* - 'ZoomScrubberPosition()': adjusts the scrubber when there is a zoom update
* - 'updateAudioPosition(qint64 duration)': Updates audio track duration
* - 'AudioLoaded()': allows for the segmenting functionality to start after audio has been loaded in
* - 'updateTrackPositionFromSegment(QPair<double, double> startEnd)': updates the audio to play the displayed segment
* - 'segmentIntervalControlsEnable(bool ready)': enables interval controls after segments are started
* - 'void segmentLengthShow(int numSamples, int sampleRate)': displayes number of samples and samples divided by sampleRate on segmentLengthLabel
* - 'segmentCreateControlsEnable(bool ready)': enables the create button once segments are established
* - 'toggleBoolManualSegments(double position)': enables the clear button and sends updated delta data and indicates to use segments from the delta value
* - 'toggleBoolAutoSegments()': enables clear button and indicates the segments are the auto ones
* - 'watchForEndOfSegmentAudio(qint64 audioPosition)': watches for if the end of the indicated segment is reached if the segment play is on
* - 'handlePlayPauseButton()': deals with play pause specifically when the button for it is pressed (or if original audio needs to be paused/played)
* - 'clearSegmentsEnable(bool enable)': enable/disable the clear segments button
* - 'handleLoopClick()': if the loop action is clicked this hadles the logic to make sure audio is looped/ the button looks selected
* - 'void handleSpectWithPlay()': when the spect is loading while audio is playing, audio & time stop to prevent jumpy scrubber
* - 'void handleWavClearing()': if charts are in use and new audio is uploaded charts & data are cleared
* - 'void disableButtonsUntilAudio()': disables buttons until audio is loaded
* - 'void enableAudioAligning(bool enable)': gets signal to enable audio aligning checkbox if second audio exists
* - 'void disableAudioControls(bool disable)': disables audio2 controls if audio1 aligning checkbox is checked and only allows for scrubber actions on audio2 for user
* - 'void audioAligningSegmentControls(bool segEnabled)': if the audio aligning is on but user on audio1 wants to use segmenting, aligning is turned off
* - 'void switchControlsWithAlign(bool aligning)': forces follow scrubber on if aligning is on
*
* Notes:
* - 'WaveForm' class and 'Zoom' class are integrated for visualization and zoom functionality respectively,
* see 'wavform.h' and 'wavform.cpp' for 'WaveForm' implementation and 'zoom.h' and 'zoom.cpp' for 'Zoom implementation
* References:
* - ...
*/
Audio::Audio(QWidget *parent, QString _label, int _audioDiviceNumber)
: QWidget{parent}, audioDiviceNumber(_audioDiviceNumber), label(_label), segmentAudioPlaying(false), audio2aligned(false)
{
newAudioPlayer();
audioUploaded = false;
disableButtonsUntilAudio();
}
void Audio::newAudioPlayer(){
audioLayout = new QHBoxLayout();
setLayout(audioLayout);
wavFormAudioControlsLayout = new QVBoxLayout();
audioLayout-> addLayout(wavFormAudioControlsLayout);
audioControls = new QHBoxLayout();
wavFormControls = new QHBoxLayout();
wavFormAudioControlsLayout-> addLayout(audioControls);
wavFormAudioControlsLayout->addLayout(wavFormControls);
QVBoxLayout *wavFormVertControls = new QVBoxLayout();
QVBoxLayout *wavFormSegmentControls = new QVBoxLayout();
wavFormControls->addLayout(wavFormVertControls);
wavFormControls->addLayout(wavFormSegmentControls);
uploadAudioButton = new QPushButton("Upload");
connect(uploadAudioButton, &QPushButton::clicked, this, &Audio::uploadAudio);
audioControls->addWidget(uploadAudioButton, 0, Qt::AlignLeft);
QAction *playAction = new QAction();
connect(playAction, &QAction::triggered, this, &Audio::handlePlayPauseButton);
if (audioDiviceNumber == 0) {
playAction->setShortcut(Qt::Key_Space); // top audio play & pause: Space
} else {
playAction->setShortcut(Qt::SHIFT | Qt::Key_Space); // bottom audio: Shift+Space
}
playButton = new QToolButton;
playButton->setDefaultAction(playAction);
playButton->setIcon(QIcon(":/resources/icons/play.svg"));
playButton->setEnabled(false);
QVBoxLayout *playLoopControls = new QVBoxLayout();
audioControls-> addLayout(playLoopControls);
playLoopControls->addWidget(playButton, 0, Qt::AlignRight);
displayAndControlsLayout = new QVBoxLayout();
audioLayout->addLayout(displayAndControlsLayout);
QAction *loopAction = new QAction();
connect(loopAction, &QAction::triggered, this, &Audio::handleLoopClick);
loopButton = new QToolButton;
loopButton->setDefaultAction(loopAction);
loopButton->setIcon(QIcon(":/resources/icons/loop.svg"));
loopButton->setEnabled(false);
loopButton->setCheckable(true);
playLoopControls->addWidget(loopButton, 0, Qt::AlignRight);
//follow scrubber
followScrubber = new QCheckBox("follow scrubber");
followScrubber->setLayoutDirection(Qt::LayoutDirection::RightToLeft);
followScrubber->setCheckState(Qt::Checked);
followScrubber->setEnabled(false);
playLoopControls->addWidget(followScrubber);
//align audios
alignAllAudioFocus = new QCheckBox("allign Audios");
alignAllAudioFocus->setEnabled(false);
if(audioDiviceNumber == 0){
connect(alignAllAudioFocus, &QCheckBox::clicked, this, &Audio::switchControlsWithAlign);
alignAllAudioFocus->setLayoutDirection(Qt::LayoutDirection::RightToLeft);
playLoopControls->addWidget(alignAllAudioFocus);
}
//Zoom
zoomButtons = new Zoom(nullptr, WAVFORM_WIDTH, WAVFORM_HEIGHT);
zoomButtons->setEnabled(false);
horizontalSlider = new QSlider();
horizontalSlider->setEnabled(false);
horizontalSlider->setOrientation(Qt::Horizontal);
horizontalSlider->setMinimum(1);
horizontalSlider->setMaximum(200);
verticalSlider = new QSlider();
verticalSlider->setOrientation(Qt::Vertical);
verticalSlider->setMinimum(1);
verticalSlider->setMaximum(10);
verticalSlider->setEnabled(false);
zoomButtons->setHorizontalSlider(horizontalSlider);
zoomButtons->setVerticalSlider(verticalSlider);
//Chart
wavChart = new WavForm(WAVFORM_WIDTH, WAVFORM_HEIGHT);
connect(this, &Audio::emitLoadAudioIn, wavChart, &WavForm::uploadAudio);
connect(zoomButtons, &Zoom::zoomGraphIn, wavChart, &WavForm::updateChart);
connect(this, &Audio::emitAutoSegmentBool, wavChart, &WavForm::changeBoolAutoSegment);
connect(followScrubber, &QCheckBox::checkStateChanged, wavChart, &WavForm::changeCenterOnScrubber);
QHBoxLayout *ChartAndVerticalSliderLayout = new QHBoxLayout();
displayAndControlsLayout->addLayout(ChartAndVerticalSliderLayout);
ChartAndVerticalSliderLayout->addWidget(wavChart);
ChartAndVerticalSliderLayout->addWidget(verticalSlider);
//zoom next to it
displayAndControlsLayout->addWidget(horizontalSlider);
//Timer/scrubber
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &Audio::updateTrackPositionFromTimer);
timerRefreshRate = 10;
connect(this, &Audio::audioPositionChanged, wavChart, &WavForm::updateScrubberPosition);
connect(this->wavChart, &WavForm::sendAudioPosition, this, &Audio::updateTrackPositionFromScrubber);
connect(zoomButtons, &Zoom::zoomGraphIn, this, &Audio::ZoomScrubberPosition);
//WavForm Controls
//Delta selector (change distance between segment lines when in segmenting control)
deltaSelector = new QDoubleSpinBox();
deltaSelector->setValue(10.0);
deltaSelector-> setMinimum(10.0);
deltaSelector->setMaximum(200);
deltaSelector->setEnabled(false);
//auto Segments button: finds max peaks to automatically segment
autoSegmentButton = new QPushButton("auto");
autoSegmentButton->setEnabled(false);
connect(deltaSelector, &QDoubleSpinBox::valueChanged, this, &Audio::toggleBoolManualSegments);
connect(autoSegmentButton, &QPushButton::clicked, this, &Audio::toggleBoolAutoSegments);
connect(wavChart, &WavForm::segmentReady, this, &Audio::segmentIntervalControlsEnable);
connect(wavChart, &WavForm::segmentLength, this, &Audio::segmentLengthShow);
QHBoxLayout *deltaLayout = new QHBoxLayout();
deltaLayout->addWidget(deltaSelector);
deltaLayout->addWidget(autoSegmentButton);
wavFormVertControls->addLayout(deltaLayout);
//graph audio segments controls
graphAudioSegments = new WaveFormSegments();
createGraphSegmentsButton = new QPushButton("create segment graphs");
createGraphSegmentsButton->setEnabled(false);
wavFormVertControls->addWidget(createGraphSegmentsButton);
connect(wavChart, &WavForm::audioFileLoadedTrue, this, &Audio::audioLoaded);
segmentToolsCheckbox = new QCheckBox("segment controls");
segmentToolsCheckbox->setEnabled(false);
connect(segmentToolsCheckbox, &QCheckBox::clicked, wavChart, &WavForm::switchMouseEventControls);
connect(segmentToolsCheckbox, &QCheckBox::clicked, this, &Audio::audioAligningSegmentControls);
segmentLengthLabel = new QLabel();
segmentLengthLabel->setVisible(false);
connect(createGraphSegmentsButton, &QPushButton::clicked, wavChart, &WavForm::sendIntervalsForSegment);
connect(wavChart, &WavForm::intervalsForSegments, graphAudioSegments, &WaveFormSegments::collectWavSegment);
//clearing all intervals (for what we send to close analysis graphs)
clearAllGraphSegmentsButton = new QPushButton("clear segments");
clearAllGraphSegmentsButton->setEnabled(false);
wavFormVertControls->addWidget(clearAllGraphSegmentsButton);
connect(clearAllGraphSegmentsButton, &QPushButton::clicked, graphAudioSegments, &WaveFormSegments::clearAllWavSegments);
connect(clearAllGraphSegmentsButton, &QPushButton::clicked, wavChart, &WavForm::clearIntervals);
connect(wavChart, &WavForm::chartInfoReady, this, &Audio::segmentCreateControlsEnable);
wavFormSegmentControls-> addWidget(segmentToolsCheckbox);
wavFormSegmentControls-> addWidget(segmentLengthLabel);
//Close Analysis Graphs
segmentGraph = new SegmentGraph(WAVFORM_WIDTH, WAVFORM_HEIGHT);
segmentGraph->setVisible(false);
connect(segmentGraph, &SegmentGraph::clearSegmentsEnable, this, &Audio::clearSegmentsEnable);
connect(wavChart, &WavForm::clearEnable, this, &Audio::clearSegmentsEnable);
connect(graphAudioSegments, &WaveFormSegments::createWavSegmentGraphs, segmentGraph, &SegmentGraph::updateGraphs);
connect(graphAudioSegments, &WaveFormSegments::storeStartEndValuesOfSegments, segmentGraph, &SegmentGraph::getSegmentStartEnd);
connect(graphAudioSegments, &WaveFormSegments::drawAutoSegments, wavChart, &WavForm::drawAutoIntervals);
connect(wavChart, &WavForm::clearAllSegmentInfo, segmentGraph, &SegmentGraph::clearView);
connect(wavChart, &WavForm::clearAllSegmentInfo, graphAudioSegments, &WaveFormSegments::clearAllWavSegments);
connect(segmentGraph, &SegmentGraph::sendPlaySegmentAudio, this, &Audio::updateTrackPositionFromSegment);
connect(this, &Audio::segmentAudioNotPlaying,segmentGraph, &SegmentGraph::changePlayPauseButton);
audioLayout->addWidget(segmentGraph);
}
void Audio::uploadAudio(){
handleSpectWithPlay();
disableButtonsUntilAudio();
QUrl aName = QFileDialog::getOpenFileUrl(this, "Select audio file");
if (aName.isEmpty()) return;
audioUploaded = true;
disableButtonsUntilAudio();
handleWavClearing();
if (player) player = nullptr;
if(audioOutput) audioOutput = nullptr;
player = new QMediaPlayer;
audioOutput = new QAudioOutput;
player->setAudioOutput(audioOutput);
player->setSource(aName);
audioOutput->setVolume(50);
connect(player, &QMediaPlayer::positionChanged, this, &Audio::watchForEndOfSegmentAudio);
playButton->setEnabled(true);
loopButton->setEnabled(true);
followScrubber->setEnabled(true);
emit emitLoadAudioIn(aName.toLocalFile());
zoomButtons->setEnabled(true);
zoomButtons->resetZoom();
setTrackPosition(player->position());
// Connect scrubber to spectrograph updates
connect(player, &QMediaPlayer::positionChanged, this, &Audio::updateTrackPositionFromTimer);
// Connect to durationChanged signal to get the actual duration
connect(player, &QMediaPlayer::durationChanged, this, &Audio::updateAudioDuration);
// emit signal to notify the spectrograph
emit audioFileSelected(aName.toLocalFile());
if(audioDiviceNumber == 1){
emit secondAudioExists(true);
}
}
void Audio::handlePlayPauseButton(){
QIcon icon = audioPlaying ? QIcon(":/resources/icons/play.svg") : QIcon(":/resources/icons/pause.svg");
playButton->setIcon(icon);
if (segmentAudioPlaying){
player->setPosition(audioPositionOnChart);
segmentAudioPlaying = false;
}
handlePlayPause();
emit segmentAudioNotPlaying(true);
}
void Audio::handlePlayPause() {
if (audioPlaying) {
player->pause();
timer->stop();
}
else {
player->play();
timer->start(timerRefreshRate);
}
setTrackPosition(player->position());
audioPlaying = !audioPlaying;
emit playPauseActivated();
}
// this is a slot with no arguments that updates position automatically using setTrackPosition
void Audio::updateTrackPositionFromTimer() {
qint64 updateVal = player->position();
if (updateVal == player->duration()) {
updateVal = audioPosition + timerRefreshRate;
} else if (updateVal != 0) {
if (prevPosition == 0) {
timeElapsed = updateVal / timerRefreshRate;
} else {
++timeElapsed;
}
if (prevPosition != updateVal) {
audioVelocity = updateVal / timeElapsed;
qint64 propVal = audioPosition + audioVelocity;
if (propVal < updateVal) {
++audioVelocity;
} else if (propVal > updateVal) {
--audioVelocity;
}
updateVal = propVal;
} else {
updateVal = audioPosition + audioVelocity;
}
}
prevPosition = player->position();
setTrackPosition(updateVal);
}
void Audio::updateTrackPositionFromScrubber(double position) {
double scaledPosition = (double) (position * audioLength);
player->setPosition(scaledPosition);
setTrackPosition(scaledPosition);
segmentAudioPlaying = false;
emit segmentAudioNotPlaying(true);
emit scrubberUpdate(position);
if (alignAllAudioFocus->isChecked()) {
if (audioPlaying) handlePlayPauseButton();
emit audioEnded(false);
}
}
void Audio::updateTrackPositionFromSegment(QPair<double, double> startEnd){
segmentAudioStartPosition = (qint64) (startEnd.first * audioLength);
setTrackPosition(segmentAudioStartPosition);
player->setPosition(segmentAudioStartPosition);
segmentAudioPlaying= true;
segmentAudioEndPosition = (qint64)(startEnd.second * audioLength);
handlePlayPause();
}
void Audio::watchForEndOfSegmentAudio(qint64 audioPos){
if(!segmentAudioPlaying) return;
if (audioPos >= segmentAudioEndPosition){
setTrackPosition(segmentAudioStartPosition);
player->setPosition(segmentAudioStartPosition);
}
}
void Audio::handleLoopClick(){
loopButton->setChecked(!loopButton->isChecked());
}
void Audio::toggleBoolManualSegments(double position) {
autoSegmentBool = false;
wavChart->updateDelta(position);
if (!clearAllGraphSegmentsButton->isEnabled())clearAllGraphSegmentsButton->setEnabled(true);
emit emitAutoSegmentBool(autoSegmentBool);
}
void Audio::toggleBoolAutoSegments() {
autoSegmentBool = true;
if (!clearAllGraphSegmentsButton->isEnabled())clearAllGraphSegmentsButton->setEnabled(true);
emit emitAutoSegmentBool(autoSegmentBool);
}
void Audio::ZoomScrubberPosition(){
double floatPosition = (double) audioPosition / audioLength;
emit audioPositionChanged(floatPosition);
}
void Audio::setTrackPosition(qint64 position) {
audioPosition = position;
double floatPosition = (double) audioPosition / audioLength;
if (floatPosition < 1.0 & abs(audioPosition - player->position()) > 100) {
audioPosition = player->position();
}
if(floatPosition > 1.05 && (alignAllAudioFocus->isChecked() || audio2aligned)){
QIcon icon = QIcon(":/resources/icons/play.svg");
playButton->setIcon(icon);
audioPlaying = false;
emit segmentAudioNotPlaying(true);
player->pause();
timer->stop();
if(audio2aligned) {
emit audioEnded(true);
emit audioPositionChanged(floatPosition);
return;
}
emit audioEnded(false);
emit audioPositionChanged(floatPosition);
return;
}
// set to 1.05 so i don't accidentally trigger with pausing right before end
// the timer and player position can be out of sync
if (floatPosition > 1.05 && !loopButton->isChecked()){
floatPosition = 0;
QIcon icon = QIcon(":/resources/icons/play.svg");
playButton->setIcon(icon);
audioPlaying = false;
emit segmentAudioNotPlaying(true);
player->pause();
timer->stop();
}
if(loopButton->isChecked() && floatPosition > 1){
player->play();
timer->start(timerRefreshRate);
setTrackPosition(player->position());
}
emit audioPositionChanged(floatPosition);
}
void Audio::updateAudioDuration(qint64 duration){
audioLength = duration;
}
void Audio::audioLoaded(){
graphAudioSegments->uploadAudio(wavChart->getSamples());
}
// we want the segments to be whatever the last button hit was
// so when auto is clicked it makes them auto
void Audio::segmentIntervalControlsEnable(bool ready){
deltaSelector->setEnabled(ready);
autoSegmentButton->setEnabled(ready);
segmentLengthLabel->setVisible(ready);
}
void Audio::segmentLengthShow(int numSamples, int sampleRate) {
double timeSecs = double(numSamples) / double (sampleRate);
QString formattedTime = QString::number(timeSecs, 'f', 3);
segmentLengthLabel->setText(QString("Length of segment:\n%1 samples\nor %2 seconds").arg(numSamples).arg(formattedTime));
}
void Audio::segmentCreateControlsEnable(bool ready){
createGraphSegmentsButton->setEnabled(ready);
audioPositionOnChart = player? player->position(): 0;
}
void Audio::clearSegmentsEnable(bool enable){
clearAllGraphSegmentsButton->setEnabled(enable);
}
// when the spect is loading while audio is playing
// audio & time should stop to prevent jumpy scrubber
void Audio::handleSpectWithPlay() {
// if player exists and playing
if (player && player->playbackState() == QMediaPlayer::PlayingState) {
player->stop(); // stop playback
timer->stop(); // stop timer updates
audioPosition = 0; // reset track pos to beginning
emit audioPositionChanged(0.0);
// update pay button to state play
audioPlaying = false;
playButton->setIcon(QIcon(":/resources/icons/play.svg"));
}
}
// if charts in use and new audio is uploaded charts & data should be cleaned up
void Audio::handleWavClearing() {
if (!segmentGraph) return;
if (!wavChart) return;
if (segmentGraph || wavChart ) {
segmentGraph->clearView();
wavChart->clearIntervals();
}
}
void Audio::disableButtonsUntilAudio() {
autoSegmentButton->setEnabled(audioUploaded);
clearAllGraphSegmentsButton->setEnabled(audioUploaded);
createGraphSegmentsButton->setEnabled(audioUploaded);
deltaSelector->setEnabled(audioUploaded);
zoomButtons->setEnabled(audioUploaded);
verticalSlider->setEnabled(audioUploaded);
horizontalSlider->setEnabled(audioUploaded);
segmentToolsCheckbox->setEnabled(audioUploaded);
}
void Audio::enableAudioAligning(bool enable){ /////////////////////////////////////////////
alignAllAudioFocus->setEnabled(enable);
}
void Audio::switchControlsWithAlign(bool aligning){
loopButton->setEnabled(!aligning);
followScrubber->setEnabled(!aligning);
followScrubber->setChecked(true);
}
void Audio::audioAligningSegmentControls(bool segEnabled){
if(alignAllAudioFocus->isEnabled() && segEnabled) {
alignAllAudioFocus->click();
}
else if(!segEnabled && audio2aligned){
alignAllAudioFocus->setEnabled(true);
qDebug() << "audioAligningSegmentControls callled";
}
}
void Audio::disableAudioControls(bool disable){
if(disable){
graphAudioSegments->clearAllWavSegments();
wavChart->clearIntervals();
segmentToolsCheckbox->setChecked(false);
wavChart->switchMouseEventControls(false);
}
audio2aligned = disable;
if (autoSegmentButton->isEnabled()) autoSegmentButton->setDisabled(disable);
if (clearAllGraphSegmentsButton->isEnabled()) clearAllGraphSegmentsButton->setDisabled(disable);
if (createGraphSegmentsButton->isEnabled()) createGraphSegmentsButton->setDisabled(disable);
if (deltaSelector->isEnabled()) deltaSelector->setDisabled(disable);
zoomButtons->setDisabled(disable);
verticalSlider->setDisabled(disable);
horizontalSlider->setDisabled(disable);
segmentToolsCheckbox->setDisabled(disable);
playButton->setDisabled(disable);
loopButton->setDisabled(disable);
followScrubber->setDisabled(disable);
}