2
2
* export_project_dialog.cpp - implementation of dialog for exporting project
4
* Linux MultiMedia Studio
5
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox@users.sourceforge.net>
4
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
7
8
* This program is free software; you can redistribute it and/or
8
9
* modify it under the terms of the GNU General Public
43
44
#include <qprogressbar.h>
44
45
#include <qcombobox.h>
45
46
#include <qcheckbox.h>
47
47
#include <qlabel.h>
48
48
#include <qpushbutton.h>
49
#include <qapplication.h>
53
54
#include "export_project_dialog.h"
54
55
#include "song_editor.h"
56
#include "lmms_main_win.h"
57
59
#include "audio_file_wave.h"
58
60
#include "audio_file_ogg.h"
63
extern QString file_to_render;
61
66
fileEncodeDevice fileEncodeDevices[] =
312
315
if( fileEncodeDevices[idx].m_fileType == m_fileType )
314
bool success_ful = FALSE;
315
audioDevice * dev = fileEncodeDevices[idx].m_getDevInst(
322
if( fileEncodeDevices[idx].m_fileType == NULL_FILE )
327
bool success_ful = FALSE;
328
audioFileDevice * dev = fileEncodeDevices[idx].m_getDevInst(
316
329
DEFAULT_SAMPLE_RATE,
317
330
DEFAULT_CHANNELS,
322
335
m_kbpsCombo->currentText().toInt() - 64,
323
336
m_kbpsCombo->currentText().toInt() + 64
325
if( success_ful == FALSE )
327
QMessageBox::information( this,
338
if( success_ful == FALSE )
340
QMessageBox::information( this,
328
341
tr( "Export failed" ),
329
342
tr( "The project-export failed, "
330
343
"because the output-file/-"
333
346
"access to the selected "
334
347
"file/device!" ),
335
348
QMessageBox::Ok );
338
mixer::inst()->pause();
339
mixer::inst()->setAudioDevice( dev,
340
m_hqmCb->isChecked() );
341
songEditor::inst()->startExport();
342
mixer::inst()->play();
348
if( fileEncodeDevices[idx].m_fileType == NULL_FILE )
353
353
setWindowTitle( tr( "Exporting project to %1" ).arg(
354
354
QFileInfo( m_fileName ).fileName() ) );
379
379
m_cancelBtn->move( CANCEL_X_WHILE_EXPORT, CANCEL_Y_WHILE_EXPORT );
381
m_progressBarUpdateTimer = new QTimer( this );
382
connect( m_progressBarUpdateTimer, SIGNAL( timeout() ), this,
383
SLOT( redrawProgressBar() ) );
384
m_progressBarUpdateTimer->start( 100 );
383
mixer::inst()->setAudioDevice( dev, m_hqmCb->isChecked() );
384
songEditor::inst()->startExport();
387
songEditor::playPos & pp = songEditor::inst()->getPlayPos(
388
songEditor::PLAY_SONG );
390
while( songEditor::inst()->exportDone() == FALSE &&
391
songEditor::inst()->exporting() == TRUE )
393
dev->processNextBuffer();
394
int pval = pp * 100 /
395
( ( songEditor::inst()->lengthInTacts() + 1 ) * 64 );
397
m_exportProgressBar->setValue( pval );
399
m_exportProgressBar->setProgress( pval );
401
// update lmms-main-win-caption
402
lmmsMainWin::inst()->setWindowTitle( tr( "Rendering:" ) + " " +
403
QString::number( pval ) + "%" );
404
// process paint-events etc.
405
qApp->processEvents();
408
// if m_deleteFile == TRUE, user aborted export and finalization-
409
// routines were already called, so we only need to call them if
410
// export went through without any problems
411
if( m_deleteFile == FALSE )
413
finishProjectExport();
397
426
abortProjectExport();
434
// called whenever there's a reason for aborting song-export (like user-input)
435
void exportProjectDialog::abortProjectExport( void )
439
finishProjectExport();
445
void exportProjectDialog::finishProjectExport( void )
447
mixer::inst()->restoreAudioDevice();
401
449
// if the user aborted export-process, the file has to be deleted
402
450
if( m_deleteFile )
407
455
// restore window-title
408
456
lmmsMainWin::inst()->resetWindowTitle();
458
songEditor::inst()->stopExport();
460
// if we rendered file from command line, quit after export
461
if( file_to_render != "" )
463
// qApp->quit(); - doesn't work for some reason...
410
467
// let's close us...
418
// called whenever there's a reason for aborting song-export (like user-input)
419
void exportProjectDialog::abortProjectExport( void )
421
mixer::inst()->pause();
424
finishProjectExport();
430
void exportProjectDialog::finishProjectExport( void )
432
m_progressBarUpdateTimer->stop();
433
delete m_progressBarUpdateTimer;
435
mixer::inst()->restoreAudioDevice();
436
songEditor::inst()->stopExport();
438
mixer::inst()->play();
440
// this method does the final cleanup...
447
void exportProjectDialog::redrawProgressBar( void )
449
if( m_progressVal != m_oldProgressVal )
452
m_exportProgressBar->setValue( m_progressVal );
454
m_exportProgressBar->setProgress( m_progressVal );
456
// update lmms-main-win-caption
457
lmmsMainWin::inst()->setWindowTitle( tr( "Rendering:" ) + " " +
458
QString::number( m_progressVal ) + "%" );
459
m_oldProgressVal = m_progressVal;
462
if( songEditor::inst()->exportDone() == TRUE ||
463
songEditor::inst()->exporting() == FALSE )
465
finishProjectExport();
473
void exportProjectDialog::updateProgressBar( int _new_val )
475
m_progressVal = _new_val;