bool RDRenderer::ImportCart(const QString &srcfile,unsigned cartnum,int cutnum, unsigned chans,QString *err_msg) { RDAudioImport::ErrorCode err_import_code; RDAudioConvert::ErrorCode err_conv_code; RDSettings settings; settings.setChannels(chans); settings.setNormalizationLevel(0); RDAudioImport *conv=new RDAudioImport(this); conv->setCartNumber(cartnum); conv->setCutNumber(cutnum); conv->setSourceFile(srcfile); conv->setUseMetadata(false); conv->setDestinationSettings(&settings); err_import_code= conv->runImport(rda->user()->name(),rda->user()->password(),&err_conv_code); *err_msg=RDAudioImport::errorText(err_import_code,err_conv_code); delete conv; return err_import_code==RDAudioImport::ErrorOk; }
bool __RDRenderLogLine::GetCutFile(const QString &cutname,int start_pt, int end_pt,QString *dest_filename) const { bool ret=false; RDAudioConvert::ErrorCode conv_err; RDAudioExport::ErrorCode export_err; char tempdir[PATH_MAX]; strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX); *dest_filename=QString(mkdtemp(tempdir))+"/"+cutname+".wav"; RDAudioExport *conv=new RDAudioExport(); conv->setDestinationFile(*dest_filename); conv->setCartNumber(RDCut::cartNumber(cutname)); conv->setCutNumber(RDCut::cutNumber(cutname)); RDSettings s; s.setFormat(RDSettings::Pcm16); s.setSampleRate(rda->system()->sampleRate()); s.setChannels(ll_channels); s.setNormalizationLevel(0); conv->setDestinationSettings(&s); conv->setRange(start_pt,end_pt); conv->setEnableMetadata(false); switch(export_err=conv->runExport(rda->user()->name(), rda->user()->password(),&conv_err)) { case RDAudioExport::ErrorOk: ret=true; break; default: ret=false; printf("export err %d [%s]\n",export_err, (const char *)RDAudioExport::errorText(export_err,conv_err).toUtf8()); break; } delete conv; return ret; }
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 }