mirror of https://github.com/odrling/Aegisub
Another load of debug prints in audio code, and a semi-working commit of karaoke changes when karaoke mode is just disabled. Still very broken.
Originally committed to SVN as r1269.
This commit is contained in:
parent
65c3b424f6
commit
de107f3108
|
@ -235,6 +235,7 @@ AudioBox::~AudioBox() {
|
||||||
////////////
|
////////////
|
||||||
// Set file
|
// Set file
|
||||||
void AudioBox::SetFile(wxString file,bool FromVideo) {
|
void AudioBox::SetFile(wxString file,bool FromVideo) {
|
||||||
|
wxLogDebug(_T("AudioBox::SetFile(file=%s, FromVideo=%d)"), file.c_str(), FromVideo?1:0);
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
|
||||||
if (FromVideo) {
|
if (FromVideo) {
|
||||||
|
@ -249,7 +250,9 @@ void AudioBox::SetFile(wxString file,bool FromVideo) {
|
||||||
audioName = file;
|
audioName = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogDebug(_T("AudioBox::SetFile: setting up accelerators in frameMain"));
|
||||||
frameMain->SetAccelerators();
|
frameMain->SetAccelerators();
|
||||||
|
wxLogDebug(_T("AudioBox::SetFile: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,18 +502,24 @@ void AudioBox::OnPlayToEnd(wxCommandEvent &event) {
|
||||||
//////////////////
|
//////////////////
|
||||||
// Commit changes
|
// Commit changes
|
||||||
void AudioBox::OnCommit(wxCommandEvent &event) {
|
void AudioBox::OnCommit(wxCommandEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioBox::OnCommit"));
|
||||||
audioDisplay->SetFocus();
|
audioDisplay->SetFocus();
|
||||||
|
wxLogDebug(_T("AudioBox::OnCommit: has set focus, now committing changes"));
|
||||||
audioDisplay->CommitChanges(true);
|
audioDisplay->CommitChanges(true);
|
||||||
|
wxLogDebug(_T("AudioBox::OnCommit: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Toggle karaoke
|
// Toggle karaoke
|
||||||
void AudioBox::OnKaraoke(wxCommandEvent &event) {
|
void AudioBox::OnKaraoke(wxCommandEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioBox::OnKaraoke"));
|
||||||
audioDisplay->SetFocus();
|
audioDisplay->SetFocus();
|
||||||
if (karaokeMode) {
|
if (karaokeMode) {
|
||||||
|
wxLogDebug(_T("AudioBox::OnKaraoke: karaoke enabled, disabling"));
|
||||||
if (audioKaraoke->splitting) {
|
if (audioKaraoke->splitting) {
|
||||||
audioKaraoke->EndSplit(true);
|
wxLogDebug(_T("AudioBox::OnKaraoke: was splitting, committing"));
|
||||||
|
audioKaraoke->Commit(); // FIXME: the grid and editbox don't seem to get updated by this
|
||||||
}
|
}
|
||||||
karaokeMode = false;
|
karaokeMode = false;
|
||||||
audioKaraoke->enabled = false;
|
audioKaraoke->enabled = false;
|
||||||
|
@ -520,11 +529,14 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
wxLogDebug(_T("AudioBox::OnKaraoke: karaoke disabled, enabling"));
|
||||||
karaokeMode = true;
|
karaokeMode = true;
|
||||||
audioKaraoke->enabled = true;
|
audioKaraoke->enabled = true;
|
||||||
SetKaraokeButtons(true,true);
|
SetKaraokeButtons(true,true);
|
||||||
audioDisplay->SetDialogue();
|
audioDisplay->SetDialogue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogDebug(_T("AudioBox::OnKaraoke: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -546,6 +558,7 @@ void AudioBox::SetKaraokeButtons(bool join,bool split) {
|
||||||
///////////////
|
///////////////
|
||||||
// Join button
|
// Join button
|
||||||
void AudioBox::OnJoin(wxCommandEvent &event) {
|
void AudioBox::OnJoin(wxCommandEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioBox::OnJoin"));
|
||||||
audioDisplay->SetFocus();
|
audioDisplay->SetFocus();
|
||||||
audioKaraoke->Join();
|
audioKaraoke->Join();
|
||||||
}
|
}
|
||||||
|
@ -554,6 +567,7 @@ void AudioBox::OnJoin(wxCommandEvent &event) {
|
||||||
////////////////
|
////////////////
|
||||||
// Split button
|
// Split button
|
||||||
void AudioBox::OnSplit(wxCommandEvent &event) {
|
void AudioBox::OnSplit(wxCommandEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioBox::OnSplit"));
|
||||||
audioDisplay->SetFocus();
|
audioDisplay->SetFocus();
|
||||||
if (!audioKaraoke->splitting) {
|
if (!audioKaraoke->splitting) {
|
||||||
audioKaraoke->BeginSplit();
|
audioKaraoke->BeginSplit();
|
||||||
|
|
|
@ -132,6 +132,7 @@ AudioDisplay::~AudioDisplay() {
|
||||||
/////////
|
/////////
|
||||||
// Reset
|
// Reset
|
||||||
void AudioDisplay::Reset() {
|
void AudioDisplay::Reset() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Reset"));
|
||||||
hasSel = false;
|
hasSel = false;
|
||||||
diagUpdated = false;
|
diagUpdated = false;
|
||||||
NeedCommit = false;
|
NeedCommit = false;
|
||||||
|
@ -681,6 +682,7 @@ void AudioDisplay::RecreateImage() {
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Make dialogue visible
|
// Make dialogue visible
|
||||||
void AudioDisplay::MakeDialogueVisible(bool force) {
|
void AudioDisplay::MakeDialogueVisible(bool force) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::MakeDialogueVisible(force=%d)"), force?1:0);
|
||||||
// Variables
|
// Variables
|
||||||
int temp1=0,temp2=0;
|
int temp1=0,temp2=0;
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
|
@ -712,6 +714,7 @@ void AudioDisplay::MakeDialogueVisible(bool force) {
|
||||||
////////////////
|
////////////////
|
||||||
// Set position
|
// Set position
|
||||||
void AudioDisplay::SetPosition(int pos) {
|
void AudioDisplay::SetPosition(int pos) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetPosition(pos=%d)"), pos);
|
||||||
Position = pos;
|
Position = pos;
|
||||||
PositionSample = pos * samples;
|
PositionSample = pos * samples;
|
||||||
UpdateImage();
|
UpdateImage();
|
||||||
|
@ -796,9 +799,11 @@ void AudioDisplay::SetScale(float _scale) {
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Load from file
|
// Load from file
|
||||||
void AudioDisplay::SetFile(wxString file, VideoProvider *vproviderLOL) {
|
void AudioDisplay::SetFile(wxString file) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile(file=%s, vproviderLOL=%p)"), file.c_str());
|
||||||
// Unload
|
// Unload
|
||||||
if (file.IsEmpty()) {
|
if (file.IsEmpty()) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: file is empty, just closing audio"));
|
||||||
if (player) player->CloseStream();
|
if (player) player->CloseStream();
|
||||||
delete provider;
|
delete provider;
|
||||||
delete player;
|
delete player;
|
||||||
|
@ -814,12 +819,15 @@ void AudioDisplay::SetFile(wxString file, VideoProvider *vproviderLOL) {
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
else {
|
else {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: unloading old file"));
|
||||||
SetFile(_T(""));
|
SetFile(_T(""));
|
||||||
try {
|
try {
|
||||||
// Get provider
|
// Get provider
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: get audio provider"));
|
||||||
provider = AudioProviderFactory::GetAudioProvider(file);
|
provider = AudioProviderFactory::GetAudioProvider(file);
|
||||||
|
|
||||||
// Get player
|
// Get player
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: get audio player"));
|
||||||
player = AudioPlayerFactory::GetAudioPlayer();
|
player = AudioPlayerFactory::GetAudioPlayer();
|
||||||
player->SetDisplayTimer(&UpdateTimer);
|
player->SetDisplayTimer(&UpdateTimer);
|
||||||
player->SetProvider(provider);
|
player->SetProvider(provider);
|
||||||
|
@ -827,12 +835,14 @@ void AudioDisplay::SetFile(wxString file, VideoProvider *vproviderLOL) {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
// Add to recent
|
// Add to recent
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: add to recent"));
|
||||||
Options.AddToRecentList(file,_T("Recent aud"));
|
Options.AddToRecentList(file,_T("Recent aud"));
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
UpdateImage();
|
UpdateImage();
|
||||||
}
|
}
|
||||||
catch (wxString &err) {
|
catch (wxString &err) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: gotcha!"));
|
||||||
wxMessageBox(err,_T("Error loading audio"),wxICON_ERROR | wxOK);
|
wxMessageBox(err,_T("Error loading audio"),wxICON_ERROR | wxOK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -840,19 +850,22 @@ void AudioDisplay::SetFile(wxString file, VideoProvider *vproviderLOL) {
|
||||||
assert(loaded == (provider != NULL));
|
assert(loaded == (provider != NULL));
|
||||||
|
|
||||||
// Set default selection
|
// Set default selection
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: set default selection"));
|
||||||
int n = grid->editBox->linen;
|
int n = grid->editBox->linen;
|
||||||
SetDialogue(grid,grid->GetDialogue(n),n);
|
SetDialogue(grid,grid->GetDialogue(n),n);
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFile: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Load from video
|
// Load from video
|
||||||
void AudioDisplay::SetFromVideo() {
|
void AudioDisplay::SetFromVideo() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetFromVideo"));
|
||||||
if (VideoContext::Get()->IsLoaded()) {
|
if (VideoContext::Get()->IsLoaded()) {
|
||||||
wxString extension = VideoContext::Get()->videoName.Right(4);
|
wxString extension = VideoContext::Get()->videoName.Right(4);
|
||||||
extension.LowerCase();
|
extension.LowerCase();
|
||||||
|
|
||||||
if (extension != _T(".d2v")) SetFile(VideoContext::Get()->videoName, VideoContext::Get()->GetProvider());
|
if (extension != _T(".d2v")) SetFile(VideoContext::Get()->videoName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,6 +873,7 @@ void AudioDisplay::SetFromVideo() {
|
||||||
////////////////
|
////////////////
|
||||||
// Reload audio
|
// Reload audio
|
||||||
void AudioDisplay::Reload() {
|
void AudioDisplay::Reload() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Reload"));
|
||||||
if (provider) SetFile(provider->GetFilename());
|
if (provider) SetFile(provider->GetFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,12 +934,15 @@ __int64 AudioDisplay::GetSampleAtMS(__int64 ms) {
|
||||||
////////
|
////////
|
||||||
// Play
|
// Play
|
||||||
void AudioDisplay::Play(int start,int end) {
|
void AudioDisplay::Play(int start,int end) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play"));
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
// Check provider
|
// Check provider
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: no audio provider"));
|
||||||
// Load temporary provider from video
|
// Load temporary provider from video
|
||||||
if (VideoContext::Get()->IsLoaded()) {
|
if (VideoContext::Get()->IsLoaded()) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: has video provider"));
|
||||||
try {
|
try {
|
||||||
// Get provider
|
// Get provider
|
||||||
provider = AudioProviderFactory::GetAudioProvider(VideoContext::Get()->videoName, 0);
|
provider = AudioProviderFactory::GetAudioProvider(VideoContext::Get()->videoName, 0);
|
||||||
|
@ -936,15 +953,21 @@ void AudioDisplay::Play(int start,int end) {
|
||||||
player->SetProvider(provider);
|
player->SetProvider(provider);
|
||||||
player->OpenStream();
|
player->OpenStream();
|
||||||
temporary = true;
|
temporary = true;
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: got temp audio provider from video provider"));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: exception getting audio provider from video, returning"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!provider) return;
|
if (!provider) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: has no provider, returning"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: initialising playback"));
|
||||||
__int64 num_samples = provider->GetNumSamples();
|
__int64 num_samples = provider->GetNumSamples();
|
||||||
start = GetSampleAtMS(start);
|
start = GetSampleAtMS(start);
|
||||||
if (end != -1) end = GetSampleAtMS(end);
|
if (end != -1) end = GetSampleAtMS(end);
|
||||||
|
@ -959,12 +982,14 @@ void AudioDisplay::Play(int start,int end) {
|
||||||
|
|
||||||
// Call play
|
// Call play
|
||||||
player->Play(start,end-start);
|
player->Play(start,end-start);
|
||||||
|
wxLogDebug(_T("AudioDisplay::Play: playback started, returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////
|
////////
|
||||||
// Stop
|
// Stop
|
||||||
void AudioDisplay::Stop() {
|
void AudioDisplay::Stop() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Stop"));
|
||||||
if (VideoContext::Get()->IsPlaying()) VideoContext::Get()->Stop();
|
if (VideoContext::Get()->IsPlaying()) VideoContext::Get()->Stop();
|
||||||
if (player) player->Stop();
|
if (player) player->Stop();
|
||||||
}
|
}
|
||||||
|
@ -973,6 +998,7 @@ void AudioDisplay::Stop() {
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
// Get samples of dialogue
|
// Get samples of dialogue
|
||||||
void AudioDisplay::GetTimesDialogue(int &start,int &end) {
|
void AudioDisplay::GetTimesDialogue(int &start,int &end) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::GetTimesDialogue"));
|
||||||
if (!dialogue) {
|
if (!dialogue) {
|
||||||
start = 0;
|
start = 0;
|
||||||
end = 0;
|
end = 0;
|
||||||
|
@ -987,6 +1013,7 @@ void AudioDisplay::GetTimesDialogue(int &start,int &end) {
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Get samples of selection
|
// Get samples of selection
|
||||||
void AudioDisplay::GetTimesSelection(int &start,int &end) {
|
void AudioDisplay::GetTimesSelection(int &start,int &end) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::GetTimesSelection"));
|
||||||
start = 0;
|
start = 0;
|
||||||
end = 0;
|
end = 0;
|
||||||
if (!dialogue) return;
|
if (!dialogue) return;
|
||||||
|
@ -1010,6 +1037,7 @@ void AudioDisplay::GetTimesSelection(int &start,int &end) {
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Set the current selection
|
// Set the current selection
|
||||||
void AudioDisplay::SetSelection(int start, int end) {
|
void AudioDisplay::SetSelection(int start, int end) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetSelection(start=%d, end=%d)"), start, end);
|
||||||
curStartMS = start;
|
curStartMS = start;
|
||||||
curEndMS = end;
|
curEndMS = end;
|
||||||
Update();
|
Update();
|
||||||
|
@ -1019,8 +1047,10 @@ void AudioDisplay::SetSelection(int start, int end) {
|
||||||
////////////////
|
////////////////
|
||||||
// Set dialogue
|
// Set dialogue
|
||||||
void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
|
void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue"));
|
||||||
// Actual parameters
|
// Actual parameters
|
||||||
if (_grid) {
|
if (_grid) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue: has grid"));
|
||||||
// Set variables
|
// Set variables
|
||||||
grid = _grid;
|
grid = _grid;
|
||||||
line_n = n;
|
line_n = n;
|
||||||
|
@ -1032,6 +1062,7 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
|
||||||
|
|
||||||
// Set times
|
// Set times
|
||||||
if (dialogue && !dontReadTimes && Options.AsBool(_T("Audio grab times on select"))) {
|
if (dialogue && !dontReadTimes && Options.AsBool(_T("Audio grab times on select"))) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue: grabbing times"));
|
||||||
int s = dialogue->Start.GetMS();
|
int s = dialogue->Start.GetMS();
|
||||||
int e = dialogue->End.GetMS();
|
int e = dialogue->End.GetMS();
|
||||||
|
|
||||||
|
@ -1045,21 +1076,25 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
|
||||||
|
|
||||||
// Read karaoke data
|
// Read karaoke data
|
||||||
if (dialogue && karaoke->enabled) {
|
if (dialogue && karaoke->enabled) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue: in karaoke mode, loading new line into karaoke control"));
|
||||||
NeedCommit = karaoke->LoadFromDialogue(dialogue);
|
NeedCommit = karaoke->LoadFromDialogue(dialogue);
|
||||||
|
|
||||||
// Reset karaoke pos
|
// Reset karaoke pos
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue: resetting karaoke position"));
|
||||||
if (karaoke->curSyllable == -1) karaoke->SetSyllable((int)karaoke->syllables.size()-1);
|
if (karaoke->curSyllable == -1) karaoke->SetSyllable((int)karaoke->syllables.size()-1);
|
||||||
else karaoke->SetSyllable(0);
|
else karaoke->SetSyllable(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
Update();
|
Update();
|
||||||
|
wxLogDebug(_T("AudioDisplay::SetDialogue: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Commit changes
|
// Commit changes
|
||||||
void AudioDisplay::CommitChanges (bool nextLine) {
|
void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges(nextLine=%d)"), nextLine?1:0);
|
||||||
// Loaded?
|
// Loaded?
|
||||||
if (!loaded) return;
|
if (!loaded) return;
|
||||||
|
|
||||||
|
@ -1067,12 +1102,14 @@ void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
bool wasKaraSplitting = false;
|
bool wasKaraSplitting = false;
|
||||||
bool validCommit = true;
|
bool validCommit = true;
|
||||||
if (!box->audioKaraoke->splitting) {
|
if (!box->audioKaraoke->splitting) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: was splitting karaoke"));
|
||||||
if (!NeedCommit || curEndMS < curStartMS) validCommit = false;
|
if (!NeedCommit || curEndMS < curStartMS) validCommit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update karaoke
|
// Update karaoke
|
||||||
int karSyl = 0;
|
int karSyl = 0;
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: karaoke enabled, committing it"));
|
||||||
wasKaraSplitting = box->audioKaraoke->splitting;
|
wasKaraSplitting = box->audioKaraoke->splitting;
|
||||||
karaoke->Commit();
|
karaoke->Commit();
|
||||||
karSyl = karaoke->curSyllable;
|
karSyl = karaoke->curSyllable;
|
||||||
|
@ -1080,6 +1117,7 @@ void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
|
|
||||||
// Commit ok?
|
// Commit ok?
|
||||||
if (validCommit) {
|
if (validCommit) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: valid commit"));
|
||||||
// Reset flags
|
// Reset flags
|
||||||
diagUpdated = false;
|
diagUpdated = false;
|
||||||
NeedCommit = false;
|
NeedCommit = false;
|
||||||
|
@ -1098,19 +1136,22 @@ void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
|
|
||||||
curDiag->Start.SetMS(curStartMS);
|
curDiag->Start.SetMS(curStartMS);
|
||||||
curDiag->End.SetMS(curEndMS);
|
curDiag->End.SetMS(curEndMS);
|
||||||
if (!karaoke->enabled)
|
if (!karaoke->enabled) {
|
||||||
// If user was editing karaoke stuff, that should take precedence of manual changes in the editbox,
|
// If user was editing karaoke stuff, that should take precedence of manual changes in the editbox,
|
||||||
// so only updated from editbox when not in kara mode
|
// so only updated from editbox when not in kara mode
|
||||||
curDiag->Text = grid->editBox->TextEdit->GetText();
|
curDiag->Text = grid->editBox->TextEdit->GetText();
|
||||||
|
}
|
||||||
curDiag->UpdateData();
|
curDiag->UpdateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update edit box
|
// Update edit box
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: updating time edit boxes"));
|
||||||
grid->editBox->StartTime->Update();
|
grid->editBox->StartTime->Update();
|
||||||
grid->editBox->EndTime->Update();
|
grid->editBox->EndTime->Update();
|
||||||
grid->editBox->Duration->Update();
|
grid->editBox->Duration->Update();
|
||||||
|
|
||||||
// Update grid
|
// Update grid
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: update grid"));
|
||||||
grid->editBox->Update(!karaoke->enabled);
|
grid->editBox->Update(!karaoke->enabled);
|
||||||
grid->ass->FlagAsModified(_T(""));
|
grid->ass->FlagAsModified(_T(""));
|
||||||
grid->CommitChanges();
|
grid->CommitChanges();
|
||||||
|
@ -1118,11 +1159,13 @@ void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
blockUpdate = false;
|
blockUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next line
|
// Next line (ugh what a condition, can this be simplified?)
|
||||||
if (nextLine && !karaoke->enabled && Options.AsBool(_T("Audio Next Line on Commit")) && !wasKaraSplitting) {
|
if (nextLine && !karaoke->enabled && Options.AsBool(_T("Audio Next Line on Commit")) && !wasKaraSplitting) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: going to next line"));
|
||||||
// Insert a line if it doesn't exist
|
// Insert a line if it doesn't exist
|
||||||
int nrows = grid->GetRows();
|
int nrows = grid->GetRows();
|
||||||
if (nrows == line_n + 1) {
|
if (nrows == line_n + 1) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: was on last line, inserting new"));
|
||||||
AssDialogue *def = new AssDialogue;
|
AssDialogue *def = new AssDialogue;
|
||||||
def->Start = grid->GetDialogue(line_n)->End;
|
def->Start = grid->GetDialogue(line_n)->End;
|
||||||
def->End = grid->GetDialogue(line_n)->End;
|
def->End = grid->GetDialogue(line_n)->End;
|
||||||
|
@ -1140,6 +1183,7 @@ void AudioDisplay::CommitChanges (bool nextLine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
|
wxLogDebug(_T("AudioDisplay::CommitChanges: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2029,11 +2073,14 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
|
||||||
///////////////
|
///////////////
|
||||||
// Change line
|
// Change line
|
||||||
void AudioDisplay::ChangeLine(int delta) {
|
void AudioDisplay::ChangeLine(int delta) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::ChangeLine(delta=%d)"), delta);
|
||||||
if (dialogue) {
|
if (dialogue) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::ChangeLine: has dialogue"));
|
||||||
// Get next line number and make sure it's within bounds
|
// Get next line number and make sure it's within bounds
|
||||||
int next = line_n+delta;
|
int next = line_n+delta;
|
||||||
if (next == -1) next = 0;
|
if (next == -1) next = 0;
|
||||||
if (next == grid->GetRows()) next = grid->GetRows() - 1;
|
if (next == grid->GetRows()) next = grid->GetRows() - 1;
|
||||||
|
wxLogDebug(_T("AudioDisplay::ChangeLine: next=%s"), next);
|
||||||
|
|
||||||
// Set stuff
|
// Set stuff
|
||||||
NeedCommit = false;
|
NeedCommit = false;
|
||||||
|
@ -2045,33 +2092,40 @@ void AudioDisplay::ChangeLine(int delta) {
|
||||||
else UpdateImage(false);
|
else UpdateImage(false);
|
||||||
line_n = next;
|
line_n = next;
|
||||||
}
|
}
|
||||||
|
wxLogDebug(_T("AudioDisplay::ChangeLine: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////
|
////////
|
||||||
// Next
|
// Next
|
||||||
void AudioDisplay::Next() {
|
void AudioDisplay::Next() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next"));
|
||||||
// Karaoke
|
// Karaoke
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: karaoke enables, going to next syllable"));
|
||||||
int nextSyl = karaoke->curSyllable+1;
|
int nextSyl = karaoke->curSyllable+1;
|
||||||
bool needsUpdate = true;
|
bool needsUpdate = true;
|
||||||
|
|
||||||
// Last syllable; jump to next
|
// Last syllable; jump to next
|
||||||
if (nextSyl >= (signed int)karaoke->syllables.size()) {
|
if (nextSyl >= (signed int)karaoke->syllables.size()) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: last syllable on line"));
|
||||||
// Already last?
|
// Already last?
|
||||||
if (line_n == grid->GetRows()-1) return;
|
if (line_n == grid->GetRows()-1) return;
|
||||||
|
|
||||||
if (NeedCommit) {
|
if (NeedCommit) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: uncommitted karaoke changes"));
|
||||||
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL | wxICON_QUESTION);
|
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL | wxICON_QUESTION);
|
||||||
//int result = wxNO;
|
//int result = wxNO;
|
||||||
if (result == wxYES) {
|
if (result == wxYES) {
|
||||||
CommitChanges();
|
CommitChanges();
|
||||||
}
|
}
|
||||||
else if (result == wxCANCEL) {
|
else if (result == wxCANCEL) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: cancelled, returning"));
|
||||||
karaoke->curSyllable = (int)karaoke->syllables.size()-1;
|
karaoke->curSyllable = (int)karaoke->syllables.size()-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: going to next line"));
|
||||||
nextSyl = 0;
|
nextSyl = 0;
|
||||||
karaoke->curSyllable = 0;
|
karaoke->curSyllable = 0;
|
||||||
ChangeLine(1);
|
ChangeLine(1);
|
||||||
|
@ -2079,6 +2133,7 @@ void AudioDisplay::Next() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set syllable
|
// Set syllable
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: set syllable"));
|
||||||
karaoke->SetSyllable(nextSyl);
|
karaoke->SetSyllable(nextSyl);
|
||||||
if (needsUpdate) Update();
|
if (needsUpdate) Update();
|
||||||
int start=0,end=0;
|
int start=0,end=0;
|
||||||
|
@ -2088,40 +2143,50 @@ void AudioDisplay::Next() {
|
||||||
|
|
||||||
// Plain mode
|
// Plain mode
|
||||||
else {
|
else {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: going to next line"));
|
||||||
ChangeLine(1);
|
ChangeLine(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogDebug(_T("AudioDisplay::Next: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Previous
|
// Previous
|
||||||
void AudioDisplay::Prev() {
|
void AudioDisplay::Prev() {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev"));
|
||||||
// Karaoke
|
// Karaoke
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: karaoke enabled, going to prev syllable"));
|
||||||
int nextSyl = karaoke->curSyllable-1;
|
int nextSyl = karaoke->curSyllable-1;
|
||||||
bool needsUpdate = true;
|
bool needsUpdate = true;
|
||||||
|
|
||||||
// First syllable; jump line
|
// First syllable; jump line
|
||||||
if (nextSyl < 0) {
|
if (nextSyl < 0) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: prev syllable on prev line"));
|
||||||
// Already first?
|
// Already first?
|
||||||
if (line_n == 0) return;
|
if (line_n == 0) return;
|
||||||
|
|
||||||
if (NeedCommit) {
|
if (NeedCommit) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: uncommitted karaoke changes"));
|
||||||
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL);
|
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL);
|
||||||
if (result == wxYES) {
|
if (result == wxYES) {
|
||||||
CommitChanges();
|
CommitChanges();
|
||||||
}
|
}
|
||||||
else if (result == wxCANCEL) {
|
else if (result == wxCANCEL) {
|
||||||
karaoke->curSyllable = 0;
|
karaoke->curSyllable = 0;
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: cancelled, returning"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: going to prev line"));
|
||||||
karaoke->curSyllable = -1;
|
karaoke->curSyllable = -1;
|
||||||
ChangeLine(-1);
|
ChangeLine(-1);
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set syllable
|
// Set syllable
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: set syllable"));
|
||||||
karaoke->SetSyllable(nextSyl);
|
karaoke->SetSyllable(nextSyl);
|
||||||
if (needsUpdate) Update();
|
if (needsUpdate) Update();
|
||||||
int start=0,end=0;
|
int start=0,end=0;
|
||||||
|
@ -2131,8 +2196,11 @@ void AudioDisplay::Prev() {
|
||||||
|
|
||||||
// Plain mode
|
// Plain mode
|
||||||
else {
|
else {
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: going to prev line"));
|
||||||
ChangeLine(-1);
|
ChangeLine(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogDebug(_T("AudioDisplay::Prev: returning"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2159,6 +2227,7 @@ int AudioDisplay::GetSyllableAtX(int x) {
|
||||||
////////////////
|
////////////////
|
||||||
// Focus events
|
// Focus events
|
||||||
void AudioDisplay::OnGetFocus(wxFocusEvent &event) {
|
void AudioDisplay::OnGetFocus(wxFocusEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::OnGetFocus"));
|
||||||
if (!hasFocus) {
|
if (!hasFocus) {
|
||||||
hasFocus = true;
|
hasFocus = true;
|
||||||
UpdateImage(true);
|
UpdateImage(true);
|
||||||
|
@ -2166,6 +2235,7 @@ void AudioDisplay::OnGetFocus(wxFocusEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDisplay::OnLoseFocus(wxFocusEvent &event) {
|
void AudioDisplay::OnLoseFocus(wxFocusEvent &event) {
|
||||||
|
wxLogDebug(_T("AudioDisplay::OnLoseFocus"));
|
||||||
if (hasFocus && loaded) {
|
if (hasFocus && loaded) {
|
||||||
hasFocus = false;
|
hasFocus = false;
|
||||||
UpdateImage(true);
|
UpdateImage(true);
|
||||||
|
|
|
@ -161,7 +161,7 @@ public:
|
||||||
void CommitChanges(bool nextLine=false);
|
void CommitChanges(bool nextLine=false);
|
||||||
void AddLead(bool in,bool out);
|
void AddLead(bool in,bool out);
|
||||||
|
|
||||||
void SetFile(wxString file,VideoProvider *vprovider=NULL);
|
void SetFile(wxString file);
|
||||||
void SetFromVideo();
|
void SetFromVideo();
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue