Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// Copyright (c) 2005-2010, Niels Martin Hansen
|
|
|
|
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
|
|
|
|
// Copyright (c) 2010, Amar Takhar
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file audio.cpp
|
|
|
|
/// @brief audio/ commands.
|
|
|
|
/// @ingroup command
|
|
|
|
///
|
|
|
|
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../config.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <wx/filedlg.h>
|
2011-10-10 21:30:11 +02:00
|
|
|
#include <wx/msgdlg.h>
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
2011-01-16 08:18:00 +01:00
|
|
|
#include "../ass_dialogue.h"
|
2011-09-30 22:41:56 +02:00
|
|
|
#include "../audio_box.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../audio_controller.h"
|
2011-09-28 21:44:07 +02:00
|
|
|
#include "../audio_karaoke.h"
|
2011-01-18 00:53:59 +01:00
|
|
|
#include "../audio_timing.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../compat.h"
|
|
|
|
#include "../include/aegisub/context.h"
|
|
|
|
#include "../main.h"
|
2011-07-15 06:05:22 +02:00
|
|
|
#include "../selection_controller.h"
|
|
|
|
#include "../video_context.h"
|
2011-01-16 08:18:00 +01:00
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace {
|
2011-07-15 06:05:22 +02:00
|
|
|
typedef SelectionController<AssDialogue>::Selection Selection;
|
2011-07-15 06:05:01 +02:00
|
|
|
using cmd::Command;
|
2011-07-15 06:05:22 +02:00
|
|
|
|
|
|
|
struct validate_audio_open : public Command {
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->audioController->IsAudioOpen();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @defgroup cmd-audio Audio commands.
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// Closes the currently open audio file.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_close : public validate_audio_open {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/close")
|
|
|
|
STR_MENU("&Close Audio")
|
|
|
|
STR_DISP("Close Audio")
|
|
|
|
STR_HELP("Closes the currently open audio file.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioController->CloseAudio();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Opens an audio file.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_open : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/open")
|
2011-10-01 20:35:12 +02:00
|
|
|
STR_MENU("&Open Audio File...")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Open Audio File")
|
|
|
|
STR_HELP("Opens an audio file.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-29 22:27:13 +02:00
|
|
|
try {
|
|
|
|
wxString path = lagi_wxString(OPT_GET("Path/Last/Audio")->GetString());
|
|
|
|
wxString str = wxString(_("Audio Formats")) + " (*.wav,*.mp3,*.ogg,*.flac,*.mp4,*.ac3,*.aac,*.mka,*.m4a,*.w64)|*.wav;*.mp3;*.ogg;*.flac;*.mp4;*.ac3;*.aac;*.mka;*.m4a;*.w64|"
|
|
|
|
+ _("Video Formats") + " (*.avi,*.mkv,*.ogm,*.mpg,*.mpeg)|*.avi;*.mkv;*.ogm;*.mp4;*.mpeg;*.mpg|"
|
|
|
|
+ _("All files") + " (*.*)|*.*";
|
|
|
|
wxString filename = wxFileSelector(_("Open audio file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
|
|
|
if (!filename.empty()) {
|
|
|
|
c->audioController->OpenAudio(filename);
|
|
|
|
OPT_SET("Path/Last/Audio")->SetString(STD_STR(filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (agi::Exception const& e) {
|
|
|
|
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Open a 150 minutes blank audio clip, for debugging.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_open_blank : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/open/blank")
|
|
|
|
STR_MENU("Open 2h30 Blank Audio")
|
|
|
|
STR_DISP("Open 2h30 Blank Audio")
|
|
|
|
STR_HELP("Open a 150 minutes blank audio clip, for debugging.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-28 21:43:11 +02:00
|
|
|
c->audioController->OpenAudio("dummy-audio:silence?sr=44100&bd=16&ch=1&ln=396900000");
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Open a 150 minutes noise-filled audio clip, for debugging.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_open_noise : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/open/noise")
|
|
|
|
STR_MENU("Open 2h30 Noise Audio")
|
|
|
|
STR_DISP("Open 2h30 Noise Audio")
|
|
|
|
STR_HELP("Open a 150 minutes noise-filled audio clip, for debugging.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-28 21:43:11 +02:00
|
|
|
c->audioController->OpenAudio("dummy-audio:noise?sr=44100&bd=16&ch=1&ln=396900000");
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Opens the audio from the current video file.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_open_video : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/open/video")
|
|
|
|
STR_MENU("Open Audio from &Video")
|
|
|
|
STR_DISP("Open Audio from Video")
|
|
|
|
STR_HELP("Opens the audio from the current video file.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->videoController->IsLoaded();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-09-29 22:27:13 +02:00
|
|
|
try {
|
|
|
|
c->audioController->OpenAudio(c->videoController->videoName);
|
|
|
|
}
|
|
|
|
catch (agi::Exception const& e) {
|
|
|
|
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK);
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Display audio as a frequency-power spectrograph.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_view_spectrum : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/view/spectrum")
|
|
|
|
STR_MENU("Spectrum Display")
|
|
|
|
STR_DISP("Spectrum Display")
|
|
|
|
STR_HELP("Display audio as a frequency-power spectrograph.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_RADIO)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Spectrum")->GetBool();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:15:24 +01:00
|
|
|
OPT_SET("Audio/Spectrum")->SetBool(true);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Display audio as a linear amplitude graph.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct audio_view_waveform : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("audio/view/waveform")
|
|
|
|
STR_MENU("Waveform Display")
|
|
|
|
STR_DISP("Waveform Display")
|
|
|
|
STR_HELP("Display audio as a linear amplitude graph.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_RADIO)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return !OPT_GET("Audio/Spectrum")->GetBool();
|
|
|
|
}
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:15:24 +01:00
|
|
|
OPT_SET("Audio/Spectrum")->SetBool(false);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
/// Save the audio for the selected lines.
|
2011-01-16 08:18:00 +01:00
|
|
|
struct audio_save_clip : public Command {
|
|
|
|
CMD_NAME("audio/save/clip")
|
|
|
|
STR_MENU("Create audio clip")
|
|
|
|
STR_DISP("Create audio clip")
|
|
|
|
STR_HELP("Create an audio clip of the selected line")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-01-16 08:18:00 +01:00
|
|
|
|
2011-07-15 06:05:31 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->audioController->IsAudioOpen() && !c->selectionController->GetSelectedSet().empty();
|
|
|
|
}
|
|
|
|
|
2011-01-16 08:18:00 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
Selection sel = c->selectionController->GetSelectedSet();
|
|
|
|
for (Selection::iterator it = sel.begin(); it != sel.end(); ++it) {
|
|
|
|
c->audioController->SaveClip(
|
|
|
|
wxFileSelector(_("Save audio clip"), "", "", "wav", "", wxFD_SAVE|wxFD_OVERWRITE_PROMPT, c->parent),
|
|
|
|
SampleRange(c->audioController->SamplesFromMilliseconds((*it)->Start.GetMS()),
|
|
|
|
c->audioController->SamplesFromMilliseconds((*it)->End.GetMS())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
/// Play the current audio selection
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_selection : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/selection")
|
|
|
|
STR_MENU("Play audio selection")
|
|
|
|
STR_DISP("Play audio selection")
|
|
|
|
STR_HELP("Play selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
c->audioController->PlayPrimaryRange();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Stop playing audio
|
|
|
|
struct audio_stop : public Command {
|
|
|
|
CMD_NAME("audio/stop")
|
|
|
|
STR_MENU("Stop playing")
|
|
|
|
STR_DISP("Stop playing")
|
|
|
|
STR_HELP("Stop")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
|
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->audioController->IsPlaying();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioController->Stop();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Play 500 ms before the selected audio range
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_before : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/selection/before")
|
|
|
|
STR_MENU("Play 500 ms before selection")
|
|
|
|
STR_DISP("Play 500 ms before selection")
|
|
|
|
STR_HELP("Play 500 ms before selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
SampleRange times(c->audioController->GetPrimaryPlaybackRange());
|
|
|
|
c->audioController->PlayRange(SampleRange(
|
|
|
|
times.begin() - c->audioController->SamplesFromMilliseconds(500),
|
|
|
|
times.begin()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Play 500 ms after the selected audio range
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_after : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/selection/after")
|
|
|
|
STR_MENU("Play 500 ms after selection")
|
|
|
|
STR_DISP("Play 500 ms after selection")
|
|
|
|
STR_HELP("Play 500 ms after selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
SampleRange times(c->audioController->GetPrimaryPlaybackRange());
|
|
|
|
c->audioController->PlayRange(SampleRange(
|
|
|
|
times.end(),
|
|
|
|
times.end() + c->audioController->SamplesFromMilliseconds(500)));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-10-01 20:35:37 +02:00
|
|
|
/// Play the last 500 ms of the audio range
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_end : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/selection/end")
|
|
|
|
STR_MENU("Play last 500 ms of selection")
|
|
|
|
STR_DISP("Play last 500 ms of selection")
|
|
|
|
STR_HELP("Play last 500 ms of selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
SampleRange times(c->audioController->GetPrimaryPlaybackRange());
|
|
|
|
c->audioController->PlayRange(SampleRange(
|
2011-10-01 20:35:37 +02:00
|
|
|
times.end() - std::min(
|
2011-01-18 00:53:59 +01:00
|
|
|
c->audioController->SamplesFromMilliseconds(500),
|
2011-10-01 20:35:37 +02:00
|
|
|
times.length()),
|
|
|
|
times.end()));
|
2011-01-18 00:53:59 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Play the first 500 ms of the audio range
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_begin : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/selection/begin")
|
|
|
|
STR_MENU("Play first 500 ms of selection")
|
|
|
|
STR_DISP("Play first 500 ms of selection")
|
|
|
|
STR_HELP("Play first 500 ms of selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
SampleRange times(c->audioController->GetPrimaryPlaybackRange());
|
|
|
|
c->audioController->PlayRange(SampleRange(
|
2011-10-01 20:35:37 +02:00
|
|
|
times.begin(),
|
|
|
|
times.begin() + std::min(
|
2011-01-18 00:53:59 +01:00
|
|
|
c->audioController->SamplesFromMilliseconds(500),
|
2011-10-01 20:35:37 +02:00
|
|
|
times.length())));
|
2011-01-18 00:53:59 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-10-01 20:35:37 +02:00
|
|
|
/// Play from the beginning of the audio range to the end of the file
|
2011-07-15 06:05:22 +02:00
|
|
|
struct audio_play_to_end : public validate_audio_open {
|
2011-01-18 00:53:59 +01:00
|
|
|
CMD_NAME("audio/play/to_end")
|
|
|
|
STR_MENU("Play from selection start to end of file")
|
|
|
|
STR_DISP("Play from selection start to end of file")
|
|
|
|
STR_HELP("Play from selection start to end of file")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-10-13 01:08:20 +02:00
|
|
|
c->videoController->Stop();
|
2011-01-18 00:53:59 +01:00
|
|
|
c->audioController->PlayToEnd(c->audioController->GetPrimaryPlaybackRange().begin());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Commit any pending audio timing changes
|
|
|
|
/// @todo maybe move to time?
|
|
|
|
struct audio_commit : public Command {
|
|
|
|
CMD_NAME("audio/commit")
|
|
|
|
STR_MENU("Commit")
|
|
|
|
STR_DISP("Commit")
|
|
|
|
STR_HELP("Commit")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioController->GetTimingController()->Commit();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Scroll the audio display to the current selection
|
2011-09-30 22:41:56 +02:00
|
|
|
struct audio_go_to : public validate_audio_open {
|
2011-08-27 08:30:42 +02:00
|
|
|
CMD_NAME("audio/go_to")
|
2011-01-18 00:53:59 +01:00
|
|
|
STR_MENU("Go to selection")
|
|
|
|
STR_DISP("Go to selection")
|
|
|
|
STR_HELP("Go to selection")
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
2011-09-30 22:41:56 +02:00
|
|
|
c->audioBox->ScrollToActiveLine();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Scroll the audio display left
|
|
|
|
struct audio_scroll_left : public validate_audio_open {
|
|
|
|
CMD_NAME("audio/scroll/left")
|
|
|
|
STR_MENU("Scroll left")
|
|
|
|
STR_DISP("Scroll left")
|
|
|
|
STR_HELP("Scroll the audio display left")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioBox->ScrollAudioBy(-128);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Scroll the audio display right
|
|
|
|
struct audio_scroll_right : public validate_audio_open {
|
|
|
|
CMD_NAME("audio/scroll/right")
|
|
|
|
STR_MENU("Scroll right")
|
|
|
|
STR_DISP("Scroll right")
|
|
|
|
STR_HELP("Scroll the audio display right")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioBox->ScrollAudioBy(128);
|
2011-01-18 00:53:59 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void toggle(const char *opt) {
|
|
|
|
OPT_SET(opt)->SetBool(!OPT_GET(opt)->GetBool());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Toggle autoscrolling the audio display to the selected line when switch lines
|
|
|
|
struct audio_autoscroll : public Command {
|
|
|
|
CMD_NAME("audio/opt/autoscroll")
|
|
|
|
STR_MENU("Auto scrolls audio display to selected line")
|
|
|
|
STR_DISP("Auto scrolls audio display to selected line")
|
|
|
|
STR_HELP("Auto scrolls audio display to selected line")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Auto/Scroll")->GetBool();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle("Audio/Auto/Scroll");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Toggle automatically committing changes made in the audio display
|
|
|
|
struct audio_autocommit : public Command {
|
|
|
|
CMD_NAME("audio/opt/autocommit")
|
|
|
|
STR_MENU("Automatically commit all changes")
|
|
|
|
STR_DISP("Automatically commit all changes")
|
|
|
|
STR_HELP("Automatically commit all changes")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Auto/Commit")->GetBool();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle("Audio/Auto/Commit");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Toggle automatically advancing to the next line after a commit
|
|
|
|
struct audio_autonext : public Command {
|
|
|
|
CMD_NAME("audio/opt/autonext")
|
|
|
|
STR_MENU("Auto goes to next line on commit")
|
|
|
|
STR_DISP("Auto goes to next line on commit")
|
|
|
|
STR_HELP("Auto goes to next line on commit")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Next Line on Commit")->GetBool();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle("Audio/Next Line on Commit");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-08-27 08:30:42 +02:00
|
|
|
/// Toggle spectrum analyzer mode
|
|
|
|
struct audio_toggle_spectrum : public Command {
|
|
|
|
CMD_NAME("audio/opt/spectrum")
|
|
|
|
STR_MENU("Spectrum analyzer mode")
|
|
|
|
STR_DISP("Spectrum analyzer mode")
|
|
|
|
STR_HELP("Spectrum analyzer mode")
|
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
|
|
|
|
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Spectrum")->GetBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle("Audio/Spectrum");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-18 00:54:05 +01:00
|
|
|
/// Toggle linked vertical zoom and volume
|
|
|
|
struct audio_vertical_link : public Command {
|
|
|
|
CMD_NAME("audio/opt/vertical_link")
|
|
|
|
STR_MENU("Link vertical zoom and volume sliders")
|
|
|
|
STR_DISP("Link vertical zoom and volume sliders")
|
|
|
|
STR_HELP("Link vertical zoom and volume sliders")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
2011-07-15 06:05:22 +02:00
|
|
|
|
2011-07-15 06:06:03 +02:00
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return OPT_GET("Audio/Link")->GetBool();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:54:05 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
toggle("Audio/Link");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-09-28 21:44:07 +02:00
|
|
|
/// Toggle karaoke mode
|
|
|
|
struct audio_karaoke : public Command {
|
|
|
|
CMD_NAME("audio/karaoke")
|
|
|
|
STR_MENU("Toggle karaoke mode")
|
|
|
|
STR_DISP("Toggle karaoke mode")
|
|
|
|
STR_HELP("Toggle karaoke mode")
|
|
|
|
CMD_TYPE(COMMAND_TOGGLE)
|
|
|
|
|
|
|
|
bool IsActive(const agi::Context *c) {
|
|
|
|
return c->karaoke->IsEnabled();
|
|
|
|
}
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->karaoke->SetEnabled(!c->karaoke->IsEnabled());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace cmd {
|
|
|
|
void init_audio() {
|
|
|
|
reg(new audio_autocommit);
|
|
|
|
reg(new audio_autonext);
|
|
|
|
reg(new audio_autoscroll);
|
|
|
|
reg(new audio_close);
|
|
|
|
reg(new audio_commit);
|
|
|
|
reg(new audio_go_to);
|
|
|
|
reg(new audio_open);
|
2011-07-15 06:05:22 +02:00
|
|
|
#if _DEBUG
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new audio_open_blank);
|
|
|
|
reg(new audio_open_noise);
|
2011-07-15 06:05:22 +02:00
|
|
|
#endif
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new audio_open_video);
|
|
|
|
reg(new audio_play_after);
|
|
|
|
reg(new audio_play_before);
|
|
|
|
reg(new audio_play_begin);
|
|
|
|
reg(new audio_play_end);
|
|
|
|
reg(new audio_play_selection);
|
|
|
|
reg(new audio_play_to_end);
|
|
|
|
reg(new audio_save_clip);
|
2011-09-30 22:41:56 +02:00
|
|
|
reg(new audio_scroll_left);
|
|
|
|
reg(new audio_scroll_right);
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new audio_stop);
|
2011-08-27 08:30:42 +02:00
|
|
|
reg(new audio_toggle_spectrum);
|
2011-07-15 06:05:01 +02:00
|
|
|
reg(new audio_vertical_link);
|
|
|
|
reg(new audio_view_spectrum);
|
|
|
|
reg(new audio_view_waveform);
|
2011-09-28 21:44:07 +02:00
|
|
|
reg(new audio_karaoke);
|
2011-07-15 06:05:01 +02:00
|
|
|
}
|
|
|
|
}
|