From b3ac7e40cb51e724817b7fee4e2bdbb61580705c Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 7 Jan 2007 06:36:10 +0000 Subject: [PATCH] Removed now unused Spectrum Invert Selection option (it should possibly be replaced with something else) Fixed scaling of spectrum to also take FFT size into account Fixed selection drawing in karaoke mode for spectrum Moved syllable texts to top of audio display in karaoke mode Originally committed to SVN as r733. --- aegisub/audio_display.cpp | 4 ++-- aegisub/audio_spectrum.cpp | 20 ++++++++++++-------- aegisub/changelog.txt | 1 + aegisub/dialog_options.cpp | 6 +++--- aegisub/options.cpp | 1 - aegisub/toggle_bitmap.cpp | 4 ---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/aegisub/audio_display.cpp b/aegisub/audio_display.cpp index 05940284d..9a6fc11c8 100644 --- a/aegisub/audio_display.cpp +++ b/aegisub/audio_display.cpp @@ -368,7 +368,7 @@ void AudioDisplay::UpdateImage(bool weak) { temptext.Trim(true); temptext.Trim(false); GetTextExtent(temptext,&tw,&th,NULL,NULL,&curFont); - dc.DrawText(temptext,(pos1+pos2-tw)/2,h-th-4); + dc.DrawText(temptext,(pos1+pos2-tw)/2,4); } } } @@ -551,7 +551,7 @@ void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) { if (hasSel && spectrumDisplaySelected && selStartCap < selEndCap) { dc.SelectObject(*spectrumDisplaySelected); - finaldc.Blit(selStart, 0, selEnd-selStart, h, &dc, selStart, 0); + finaldc.Blit(selStartCap, 0, selEndCap-selStartCap, h, &dc, selStartCap, 0); } } diff --git a/aegisub/audio_spectrum.cpp b/aegisub/audio_spectrum.cpp index 33c4a0439..7fb1bc43c 100644 --- a/aegisub/audio_spectrum.cpp +++ b/aegisub/audio_spectrum.cpp @@ -94,7 +94,7 @@ public: float *out_r = new float[line_length*2]; float *out_i = new float[line_length*2]; - FFT fft; // TODO: use FFTW instead? + FFT fft; // TODO: use FFTW instead? A wavelet? for (unsigned long i = 0; i < length; ++i) { provider->GetAudio(raw_sample_data, sample, line_length*2); @@ -141,7 +141,7 @@ public: { if (i >= start && i-start <= length) { // Determine which sub-cache this line resides in - int subcache = (i-start) / subcache_length; + size_t subcache = (i-start) / subcache_length; assert(subcache >= 0 && subcache < sub_caches.size()); if (!sub_caches[subcache]) { @@ -243,6 +243,13 @@ void AudioSpectrum::RenderRange(__int64 range_start, __int64 range_end, bool sel else palette = colours_normal; + // Some scaling constants + const int maxpower = (1 << (16 - 1))*256; + + const double upscale = power_scale * 16384 / line_length; + const double onethirdmaxpower = maxpower / 3, twothirdmaxpower = maxpower * 2/3; + const double logoverscale = log(maxpower*upscale - twothirdmaxpower); + for (unsigned long i = first_line; i <= last_line; ++i) { // Handle horizontal compression and don't unneededly re-render columns int imgcol = imgleft + imgwidth * (i - first_line) / (last_line - first_line + 1); @@ -251,15 +258,11 @@ void AudioSpectrum::RenderRange(__int64 range_start, __int64 range_end, bool sel AudioSpectrumCache::CacheLine &line = cache->GetLine(i); - int maxpower = (1 << (16 - 1))*256; - // Calculate the signal power over frequency // "Compressed" scale - double onethirdmaxpower = maxpower / 3, twothirdmaxpower = maxpower * 2/3; - double logoverscale = log(maxpower*8*power_scale - twothirdmaxpower); - for (int j = 0; j < line_length; j++) { + for (unsigned int j = 0; j < line_length; j++) { // First do a simple linear scale power calculation -- 8 gives a reasonable default scaling - power[j] = line[j] * 8 * power_scale; + power[j] = line[j] * upscale; if (power[j] > maxpower * 2/3) { double p = power[j] - twothirdmaxpower; p = log(p) * onethirdmaxpower / logoverscale; @@ -272,6 +275,7 @@ void AudioSpectrum::RenderRange(__int64 range_start, __int64 range_end, bool sel img[((imgheight-y-1)*imgpitch+x)*3 + 1] = palette[intensity*3+1]; \ img[((imgheight-y-1)*imgpitch+x)*3 + 2] = palette[intensity*3+2]; + // Handle horizontal expansion int next_line_imgcol = imgleft + imgwidth * (i - first_line + 1) / (last_line - first_line + 1); if (next_line_imgcol >= imgpitch) next_line_imgcol = imgpitch-1; diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index d675bd462..98bbca7d6 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -78,6 +78,7 @@ Please visit http://aegisub.net to download latest version - Fixed loading of SRT and TXT files, which were causing an empty line to appear at the start of the file. (AMZ) - Added options to toggle the display of the audio timeline and of the time over the mouse cursor. (AMZ) - Destination of screenshots can now be set in the options dialog. (AMZ) +- Moved karaoke syllable text in audio display to the top instead of bottom, since it often covers important information in spectrum mode (jfs) = 1.10 beta - 2006.08.07 =========================== diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index bd0e19474..78c72414e 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -487,9 +487,9 @@ DialogOptions::DialogOptions(wxWindow *parent) wxFlexGridSizer *displaySizer4 = new wxFlexGridSizer(14,2,2,2); // First sizer - wxString labels1[5] = { _("Spectrum Invert Selection"), _("Draw Secondary Lines"), _("Draw Selection Background"), _("Draw Timeline"), _("Draw Cursor Time") }; - wxString options1[5] = { _T("Spectrum invert selection"), _T("Draw Secondary Lines"), _T("Draw Selection Background") , _T("Draw Timeline"), _T("Draw Cursor Time")}; - for (int i=0;i<5;i++) { + wxString labels1[4] = { _("Draw Secondary Lines"), _("Draw Selection Background"), _("Draw Timeline"), _("Draw Cursor Time") }; + wxString options1[4] = { _T("Draw Secondary Lines"), _T("Draw Selection Background") , _T("Draw Timeline"), _T("Draw Cursor Time")}; + for (int i=0;i<4;i++) { wxCheckBox *control = new wxCheckBox(displayPage,-1,labels1[i]); Bind(control,_T("Audio ") + options1[i]); displaySizer3->Add(control,1,wxEXPAND | wxALL,5); diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 4fd299700..91bc0f31f 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -214,7 +214,6 @@ void OptionsManager::LoadDefaults() { // Audio Cosmetic SetModificationType(MOD_AUDIO); SetInt(_T("Audio Line boundaries Thickness"), 2); - SetBool(_T("Audio Spectrum invert selection"), true); SetBool(_T("Audio Draw Secondary Lines"), true); SetBool(_T("Audio Draw Selection Background"), true); SetBool(_T("Audio Draw Timeline"),true); diff --git a/aegisub/toggle_bitmap.cpp b/aegisub/toggle_bitmap.cpp index 48fd8f576..645057ffe 100644 --- a/aegisub/toggle_bitmap.cpp +++ b/aegisub/toggle_bitmap.cpp @@ -81,8 +81,6 @@ void ToggleBitmap::SetValue(bool _state) { ////////////// // Draw image void ToggleBitmap::DrawImage(wxDC &dc) { - dc.BeginDrawing(); - // Get size int w,h; GetClientSize(&w,&h); @@ -105,8 +103,6 @@ void ToggleBitmap::DrawImage(wxDC &dc) { // Draw bitmap dc.DrawBitmap(img,(w-img.GetWidth())/2,(h-img.GetHeight())/2,true); - - dc.EndDrawing(); }