void RDImportAudio::Import() { RDSettings settings; RDAudioImport::ErrorCode conv_err; RDAudioConvert::ErrorCode audio_conv_err; if(*import_running) { return; } import_import_button->setText(tr("Abort")); if(!QFile::exists(import_in_filename_edit->text())) { QMessageBox::warning(this,tr("Import Audio File"), tr("File does not exist!")); return; } // // Import // StartBar(); RDCut *cut=new RDCut(import_cutname); import_import_conv=new RDAudioImport(import_station,import_config,this); import_import_conv->setCartNumber(cut->cartNumber()); import_import_conv->setCutNumber(cut->cutNumber()); import_import_conv->setSourceFile(import_in_filename_edit->text()); settings.setChannels(import_channels_box->currentItem()+1); if(import_normalize_box->isChecked()) { settings.setNormalizationLevel(import_normalize_spin->value()); } if(import_autotrim_box->isChecked()) { settings.setAutotrimLevel(import_autotrim_spin->value()); } import_import_conv->setDestinationSettings(&settings); import_import_conv->setUseMetadata(import_in_metadata_box->isChecked()); *import_running=true; import_import_aborted=false; conv_err=import_import_conv->runImport(import_user->name(),import_user->password(),&audio_conv_err); *import_running=false; StopBar(); switch(conv_err) { case RDAudioImport::ErrorOk: if(import_in_metadata_box->isChecked()) { RDWaveFile *wave=new RDWaveFile(import_in_filename_edit->text()); wave->openWave(import_wavedata); wave->closeWave(); delete wave; } cut->setOriginName(import_station->name()); cut-> setOriginDatetime(QDateTime(QDate::currentDate(),QTime::currentTime())); QMessageBox::information(this,tr("Import Complete"), tr("Import complete!")); break; default: QMessageBox::warning(this,tr("Import Error"), RDAudioImport::errorText(conv_err,audio_conv_err)); } delete import_import_conv; import_import_conv=NULL; delete cut; import_import_button->setText(tr("Import")); done(0); }
void RDCartDialog::loadFileData() { #ifndef WIN32 QString filename; RDGroup *group=NULL; RDCart *cart=NULL; RDCut *cut=NULL; RDAudioImport *conv; RDAudioImport::ErrorCode err; RDAudioConvert::ErrorCode conv_err; RDSettings settings; unsigned cartnum=0; QString file_title=""; RDWaveFile *wavefile=NULL; RDWaveData wavedata; filename=Q3FileDialog::getOpenFileName(cart_import_path, cart_import_file_filter,this); if(!filename.isEmpty()) { // // Get Cart Number // cart_import_path=RDGetPathPart(filename); group=new RDGroup(rda->system()->tempCartGroup()); if((!group->exists())||((cartnum=group->nextFreeCart())==0)) { delete group; QMessageBox::warning(this,tr("Cart Error"), tr("Unable to get temporary cart number for import!")); return; } delete group; // // Create Cart // cart=new RDCart(cartnum); if(!cart->create(rda->system()->tempCartGroup(),RDCart::Audio)) { delete cart; QMessageBox::warning(this,tr("Cart Error"), tr("Unable to create temporary cart for import!")); return; } cart->setOwner(rda->station()->name()); cut=new RDCut(cartnum,1,true); // // Import Audio // cart_busy_dialog->show(tr("Importing"),tr("Importing...")); conv=new RDAudioImport(rda->station(),rda->config(),this); conv->setCartNumber(cartnum); conv->setCutNumber(1); conv->setSourceFile(filename); settings.setChannels(2); settings.setNormalizationLevel(-11); conv->setDestinationSettings(&settings); conv->setUseMetadata(true); err=conv->runImport(cart_user_name,cart_user_password,&conv_err); cart_busy_dialog->hide(); switch(conv_err) { case RDAudioImport::ErrorOk: break; default: QMessageBox::warning(this,tr("Import Error"), RDAudioImport::errorText(err,conv_err)); delete conv; delete cart; delete cut; return; } // // Check Metadata // wavefile=new RDWaveFile(filename); if(wavefile->openWave(&wavedata)) { if((!wavedata.metadataFound())||(wavedata.title().isEmpty())) { cart->setTitle(tr("Imported from")+" "+RDGetBasePart(filename)); } } *cart_cartnum=cartnum; *cart_temp_allowed=true; delete conv; delete cart; delete cut; done(0); } #endif // WIN32 }