bool BatchCommands::WriteMp3File( const wxString Name, int bitrate ) { //check if current project is mono or stereo int numChannels = 2; if (IsMono()) { numChannels = 1; } double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; AudacityProject *project = GetActiveProject(); if( bitrate <=0 ) { // 'No' bitrate given, use the current default. // Use Mp3Stereo to control if export is to a stereo or mono file return mExporter.Process(project, numChannels, wxT("MP3"), Name, false, 0.0, endTime); } bool rc; long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate); // Use Mp3Stereo to control if export is to a stereo or mono file rc = mExporter.Process(project, numChannels, wxT("MP3"), Name, false, 0.0, endTime); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate); gPrefs->Flush(); return rc; }
static void RenderGlyph(uint8_t *buffer, size_t width, size_t height, FT_GlyphSlot glyph, int x, int y) { if (IsMono()) { /* with anti-aliasing disabled, FreeType writes each pixel in one bit; hack: convert it to 1 byte per pixel and then render it */ FT_Bitmap bitmap; ConvertMono(bitmap, glyph->bitmap); RenderGlyph(buffer, width, height, bitmap, x, y); delete[] bitmap.buffer; } else RenderGlyph(buffer, width, height, glyph->bitmap, x, y); }
void Font::Initialise() { if (IsMono()) { /* disable anti-aliasing */ load_flags |= FT_LOAD_TARGET_MONO; render_mode = FT_RENDER_MODE_MONO; } font_path = FindDefaultFont(); bold_font_path = FindDefaultBoldFont(); italic_font_path = FindDefaultItalicFont(); bold_italic_font_path = FindDefaultBoldItalicFont(); monospace_font_path = FindDefaultMonospaceFont(); }
bool BatchCommands::WriteMp3File( const wxString Name, int bitrate ) { //check if current project is mono or stereo bool Mp3Stereo = true; if (IsMono()) {Mp3Stereo = false;}; double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; AudacityProject *project = GetActiveProject(); if( bitrate <=0 ) { // 'No' bitrate given, use the current default. // Use Mp3Stereo to control if export is to a stereo or mono file return ::ExportMP3(project, Mp3Stereo, Name, false, 0.0, endTime); } bool rc; long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate); // Use Mp3Stereo to control if export is to a stereo or mono file rc = ::ExportMP3(project, Mp3Stereo, Name, false, 0.0, endTime); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate); return rc; }
// TIDY-ME: Get rid of special commands and make them part of the // 'menu' system (but not showing on the menu) // // ======= IMPORTANT ======== // Special Commands are a KLUDGE whilst we wait for a better system to handle the menu // commands from batch mode. // // Really we should be using a similar (or same) system to that used for effects // so that parameters can be passed to the commands. Many of the menu // commands take a selection as their parameter. // // If you find yourself adding lots of existing commands from the menus here, STOP // and think again. // ======= IMPORTANT ======== // CLEANSPEECH remnant bool BatchCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString command,const wxString params) { if (ReportAndSkip(command, params)) return true; AudacityProject *project = GetActiveProject(); int numChannels = 1; //used to switch between mono and stereo export if (IsMono()) { numChannels = 1; //export in mono } else { numChannels = 2; //export in stereo } wxString filename; wxString extension; // required for correct message if (command == wxT("ExportWAV")) extension = wxT(".wav"); else if (command == wxT("ExportOgg")) extension = wxT(".ogg"); else if (command == wxT("ExportFLAC")) extension = wxT(".flac"); else extension = wxT(".mp3"); if (mFileName.IsEmpty()) { filename = project->BuildCleanFileName(project->GetFileName(), extension); } else { filename = project->BuildCleanFileName(mFileName, extension); } // We have a command index, but we don't use it! // TODO: Make this special-batch-command code use the menu item code.... // FIXME: No error reporting on write file failure in batch mode. if (command == wxT("NoAction")) { return true; } else if (!mFileName.IsEmpty() && command == wxT("Import")) { // historically this was in use, now ignored if there return true; } else if (command == wxT("ExportMP3_56k_before")) { filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false); return WriteMp3File(filename, 56); } else if (command == wxT("ExportMP3_56k_after")) { filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false); return WriteMp3File(filename, 56); } else if (command == wxT("StereoToMono")) { // StereoToMono is an effect masquerading as a menu item. Effect * f = EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")); if (f != NULL) { return ApplyEffectCommand(f, command, params); } wxMessageBox(_("Stereo to Mono Effect not found")); return false; } else if (command == wxT("ExportMP3")) { return WriteMp3File(filename, 0); // 0 bitrate means use default/current } else if (command == wxT("ExportWAV")) { filename.Replace(wxT(".mp3"), wxT(".wav"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("WAV"), filename, false, 0.0, endTime); } else if (command == wxT("ExportOgg")) { #ifdef USE_LIBVORBIS filename.Replace(wxT(".mp3"), wxT(".ogg"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("OGG"), filename, false, 0.0, endTime); #else wxMessageBox(_("Ogg Vorbis support is not included in this build of Audacity")); return false; #endif } else if (command == wxT("ExportFLAC")) { #ifdef USE_LIBFLAC filename.Replace(wxT(".mp3"), wxT(".flac"), false); double endTime = GetEndTime(); if (endTime <= 0.0f) { return false; } return mExporter.Process(project, numChannels, wxT("FLAC"), filename, false, 0.0, endTime); #else wxMessageBox(_("FLAC support is not included in this build of Audacity")); return false; #endif } wxMessageBox(wxString::Format(_("Command %s not implemented yet"),command.c_str())); return false; }
// TIDY-ME: Get rid of special commands and make them part of the // 'menu' system (but not showing on the menu) // // ======= IMPORTANT ======== // Special Commands are a KLUDGE whilst we wait for a better system to handle the menu // commands from batch mode. // // Really we should be using a similar (or same) system to that used for effects // so that parameters can be passed to the commands. Many of the menu // commands take a selection as their parameter. // // If you find yourself adding lots of existing commands from the menus here, STOP // and think again. // ======= IMPORTANT ======== bool BatchCommands::ApplySpecialCommand(int iCommand, const wxString command,const wxString params) { AudacityProject *project = GetActiveProject(); wxString filename; int numChannels = 1; //used to switch between mono and stereo export if (IsMono()) { numChannels = 1; //export in mono } else { numChannels = 2; //export in stereo } if( ReportAndSkip(command, params)) return true; if (mFileName.IsEmpty()) { filename = project->BuildCleanFileName(project->GetFileName()); } else { filename = project->BuildCleanFileName(mFileName); } // We have a command index, but we don't use it! // TODO: Make this special-batch-command code use the menu item code.... // FIX-ME: No error reporting on write file failure in batch mode. if( command == wxT("No Action")){ return true; } else if (!mFileName.IsEmpty() && command == wxT("Import") ){ project->OnRemoveTracks(); project->Import(mFileName); project->OnSelectAll(); return true; } else if (command == wxT("Save Hq Master1")){ filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterBefore_"), false); return WriteMp3File( filename, 56 ); } else if (command == wxT("Save Hq Master2")){ filename.Replace(wxT("cleaned/"), wxT("cleaned/MasterAfter_"), false); return WriteMp3File ( filename, 56 ); } else if (command == wxT("Stereo To Mono")){ // StereoToMono is an effect masquerading as a menu item. Effect * f=GetEffectFromCommandName( _("Stereo To Mono") ); if( f!=NULL ) return ApplyEffectCommand( f, command, params ); wxMessageBox( _("Stereo To Mono Effect not found")); return false; } else if (command == wxT("ExportMp3") ){ return WriteMp3File ( filename, 0 ); // 0 bitrate means use default/current } else if (command == wxT("ExportWav") ){ filename.Replace(wxT(".mp3"), wxT(".wav"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportPCM(project, numChannels, filename, false, 0.0, endTime); } else if (command == wxT("ExportOgg")){ #ifdef USE_LIBVORBIS filename.Replace(wxT(".mp3"), wxT(".ogg"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportOGG(project, numChannels, filename, false, 0.0, endTime); #else wxMessageBox(_("Ogg Vorbis support is not included in this build of Audacity")); return false; #endif } else if (command == wxT("ExportFlac")){ #ifdef USE_LIBFLAC filename.Replace(wxT(".mp3"), wxT(".flac"), false); double endTime = GetEndTime(); if( endTime <= 0.0f ) return false; return ::ExportFLAC(project, numChannels, filename, false, 0.0, endTime); #else wxMessageBox(_("FLAC support is not included in this build of Audacity")); return false; #endif } wxMessageBox( wxString::Format(_("Command %s not implemented yet"),command.c_str()) ); return false; }