2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro
// 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.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
2006-01-16 22:02:54 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @file audio_display.cpp
/// @brief Display audio in the main UI
/// @ingroup audio_ui
2006-01-16 22:02:54 +01:00
///////////
// Headers
2009-01-04 07:31:48 +01:00
# include "config.h"
2009-09-10 15:06:40 +02:00
# ifndef AGI_PRE
2006-08-27 21:54:51 +02:00
# include <math.h>
2009-09-10 15:06:40 +02:00
2006-08-27 21:54:51 +02:00
# include <vector>
2009-09-10 15:06:40 +02:00
# include <wx/filename.h>
# include <wx/tglbtn.h>
# endif
2006-01-16 22:02:54 +01:00
# include "ass_file.h"
# include "audio_box.h"
2009-09-10 15:06:40 +02:00
# include "audio_display.h"
# include "audio_karaoke.h"
2007-07-23 17:19:48 +02:00
# ifdef _DEBUG
# include "audio_provider_dummy.h"
# endif
2009-09-10 15:06:40 +02:00
# include "audio_provider_stream.h"
# include "colorspace.h"
2010-05-21 03:13:36 +02:00
# include "compat.h"
2009-09-10 15:06:40 +02:00
# include "fft.h"
# include "hotkeys.h"
2010-05-21 03:13:36 +02:00
# include "main.h"
2009-09-10 15:06:40 +02:00
# include "options.h"
# include "standard_paths.h"
# include "subs_edit_box.h"
# include "subs_grid.h"
# include "timeedit_ctrl.h"
# include "utils.h"
# include "vfr.h"
# include "video_context.h"
2007-09-21 23:17:08 +02:00
# ifdef __WXMAC__
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-09-21 23:17:08 +02:00
# define AudioDisplayWindowStyle wxWANTS_CHARS
# else
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2007-09-21 23:18:08 +02:00
# define AudioDisplayWindowStyle wxSUNKEN_BORDER | wxWANTS_CHARS
2007-09-21 23:17:08 +02:00
# endif
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Constructor
/// @param parent
2007-01-21 18:01:22 +01:00
AudioDisplay : : AudioDisplay ( wxWindow * parent )
2010-05-21 03:13:36 +02:00
: wxWindow ( parent , - 1 , wxDefaultPosition , wxSize ( 200 , OPT_GET ( " Audio/Display Height " ) - > GetInt ( ) ) , AudioDisplayWindowStyle , _T ( " Audio Display " ) )
2006-01-16 22:02:54 +01:00
{
// Set variables
origImage = NULL ;
spectrumDisplay = NULL ;
2007-01-07 05:44:11 +01:00
spectrumDisplaySelected = NULL ;
spectrumRenderer = NULL ;
2006-01-16 22:02:54 +01:00
ScrollBar = NULL ;
dialogue = NULL ;
karaoke = NULL ;
peak = NULL ;
min = NULL ;
hasSel = false ;
diagUpdated = false ;
NeedCommit = false ;
loaded = false ;
2006-07-01 08:32:11 +02:00
temporary = false ;
2006-01-16 22:02:54 +01:00
blockUpdate = false ;
dontReadTimes = false ;
2006-02-21 22:33:15 +01:00
holding = false ;
2006-03-07 01:12:50 +01:00
draggingScale = false ;
2006-07-04 08:13:54 +02:00
scrubbing = false ;
2006-01-16 22:02:54 +01:00
Position = 0 ;
PositionSample = 0 ;
oldCurPos = 0 ;
scale = 1.0f ;
provider = NULL ;
2006-02-25 08:41:18 +01:00
player = NULL ;
2006-01-16 22:02:54 +01:00
hold = 0 ;
2008-01-20 21:09:49 +01:00
samples = 0 ;
2008-11-25 02:52:35 +01:00
samplesPercent = 100 ;
2006-01-16 22:02:54 +01:00
hasFocus = ( wxWindow : : FindFocus ( ) = = this ) ;
2008-11-14 02:21:17 +01:00
needImageUpdate = false ;
2008-11-25 02:49:17 +01:00
needImageUpdateWeak = true ;
2009-05-22 04:27:36 +02:00
playingToEnd = false ;
2006-01-16 22:02:54 +01:00
// Init
UpdateTimer . SetOwner ( this , Audio_Update_Timer ) ;
2006-03-06 01:45:24 +01:00
GetClientSize ( & w , & h ) ;
2010-05-21 03:13:36 +02:00
h - = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2006-01-16 22:02:54 +01:00
SetSamplesPercent ( 50 , false ) ;
// Set cursor
//wxCursor cursor(wxCURSOR_BLANK);
//SetCursor(cursor);
//wxLog::SetActiveTarget(new wxLogWindow(NULL,_T("Log"),true,false));
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Destructor
2006-01-16 22:02:54 +01:00
AudioDisplay : : ~ AudioDisplay ( ) {
2006-02-25 08:41:18 +01:00
if ( player ) player - > CloseStream ( ) ;
delete provider ;
delete player ;
delete origImage ;
2007-01-07 05:44:11 +01:00
delete spectrumRenderer ;
2006-02-25 08:41:18 +01:00
delete spectrumDisplay ;
2007-01-07 05:44:11 +01:00
delete spectrumDisplaySelected ;
2009-05-22 02:05:25 +02:00
delete [ ] peak ;
delete [ ] min ;
2007-01-21 07:30:19 +01:00
provider = NULL ;
player = NULL ;
origImage = NULL ;
spectrumRenderer = NULL ;
spectrumDisplay = NULL ;
spectrumDisplaySelected = NULL ;
peak = NULL ;
min = NULL ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Reset
2006-01-16 22:02:54 +01:00
void AudioDisplay : : Reset ( ) {
hasSel = false ;
diagUpdated = false ;
NeedCommit = false ;
karaoke - > enabled = false ;
karaoke - > syllables . clear ( ) ;
box - > karaokeMode = false ;
box - > KaraokeButton - > SetValue ( false ) ;
dialogue = NULL ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update image
/// @param weak
2006-01-16 22:02:54 +01:00
void AudioDisplay : : UpdateImage ( bool weak ) {
2008-11-14 02:21:17 +01:00
// Update samples
UpdateSamples ( ) ;
// Set image as needing to be redrawn
needImageUpdate = true ;
2008-11-25 02:49:17 +01:00
if ( weak = = false & & needImageUpdateWeak = = true ) {
needImageUpdateWeak = false ;
}
2008-11-14 02:21:17 +01:00
Refresh ( false ) ;
}
2009-08-01 04:32:26 +02:00
/// @brief Actually update the image on the display
/// This is where most actual drawing of the audio display happens, or other functions
/// to draw specific parts are called from.
2008-11-14 02:21:17 +01:00
void AudioDisplay : : DoUpdateImage ( ) {
2006-07-04 23:59:30 +02:00
// Loaded?
if ( ! loaded | | ! provider ) return ;
2008-11-14 02:21:17 +01:00
// Needs updating?
if ( ! needImageUpdate ) return ;
bool weak = needImageUpdateWeak ;
2006-01-16 22:02:54 +01:00
// Prepare bitmap
2010-05-21 03:13:36 +02:00
int timelineHeight = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2007-01-06 07:14:35 +01:00
int displayH = h + timelineHeight ;
2006-01-16 22:02:54 +01:00
if ( origImage ) {
2006-03-06 01:45:24 +01:00
if ( origImage - > GetWidth ( ) ! = w | | origImage - > GetHeight ( ) ! = displayH ) {
2006-01-16 22:02:54 +01:00
delete origImage ;
origImage = NULL ;
}
}
2007-04-07 04:39:18 +02:00
// Options
2010-05-21 03:13:36 +02:00
bool draw_boundary_lines = OPT_GET ( " Audio/Display/Draw/Secondary Lines " ) - > GetBool ( ) ;
bool draw_selection_background = OPT_GET ( " Audio/Display/Draw/Selection Background " ) - > GetBool ( ) ;
bool drawKeyframes = OPT_GET ( " Audio/Display/Draw/Keyframes " ) - > GetBool ( ) ;
2006-01-16 22:02:54 +01:00
// Invalid dimensions
2006-03-06 01:45:24 +01:00
if ( w = = 0 | | displayH = = 0 ) return ;
2006-01-16 22:02:54 +01:00
// New bitmap
2006-03-06 01:45:24 +01:00
if ( ! origImage ) origImage = new wxBitmap ( w , displayH , - 1 ) ;
2006-01-16 22:02:54 +01:00
// Is spectrum?
bool spectrum = false ;
2010-05-21 03:13:36 +02:00
if ( provider & & OPT_GET ( " Audio/Spectrum " ) - > GetBool ( ) ) {
2006-01-16 22:02:54 +01:00
spectrum = true ;
}
// Draw image to be displayed
wxMemoryDC dc ;
dc . SelectObject ( * origImage ) ;
// Black background
dc . SetPen ( * wxTRANSPARENT_PEN ) ;
2010-05-21 03:13:36 +02:00
dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Background/Background " ) - > GetColour ( ) ) ) ) ;
2006-01-16 22:02:54 +01:00
dc . DrawRectangle ( 0 , 0 , w , h ) ;
// Selection position
hasSel = false ;
hasKaraoke = karaoke - > enabled ;
selStart = 0 ;
selEnd = 0 ;
lineStart = 0 ;
lineEnd = 0 ;
selStartCap = 0 ;
selEndCap = 0 ;
2007-08-31 16:11:35 +02:00
int64_t drawSelStart = 0 ;
int64_t drawSelEnd = 0 ;
2006-01-16 22:02:54 +01:00
if ( dialogue ) {
GetDialoguePos ( lineStart , lineEnd , false ) ;
hasSel = true ;
if ( hasKaraoke ) {
GetKaraokePos ( selStartCap , selEndCap , true ) ;
2007-01-06 21:11:38 +01:00
GetKaraokePos ( drawSelStart , drawSelEnd , false ) ;
selStart = lineStart ;
selEnd = lineEnd ;
2006-01-16 22:02:54 +01:00
}
else {
GetDialoguePos ( selStartCap , selEndCap , true ) ;
selStart = lineStart ;
selEnd = lineEnd ;
2007-01-06 21:11:38 +01:00
drawSelStart = lineStart ;
drawSelEnd = lineEnd ;
2006-01-16 22:02:54 +01:00
}
}
// Draw selection bg
2007-01-06 21:11:38 +01:00
if ( hasSel & & drawSelStart < drawSelEnd & & draw_selection_background ) {
2010-05-21 03:13:36 +02:00
if ( NeedCommit & & ! karaoke - > enabled ) dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Background/Selection Modified " ) - > GetColour ( ) ) ) ) ;
else dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Background/Background " ) - > GetColour ( ) ) ) ) ;
2007-01-06 21:11:38 +01:00
dc . DrawRectangle ( drawSelStart , 0 , drawSelEnd - drawSelStart , h ) ;
2006-01-16 22:02:54 +01:00
}
// Draw spectrum
if ( spectrum ) {
DrawSpectrum ( dc , weak ) ;
}
2007-04-07 04:39:18 +02:00
// Waveform
else if ( provider ) {
DrawWaveform ( dc , weak ) ;
}
// Nothing
else {
dc . DrawLine ( 0 , h / 2 , w , h / 2 ) ;
}
2006-01-16 22:02:54 +01:00
// Draw seconds boundaries
if ( draw_boundary_lines ) {
2007-08-31 16:11:35 +02:00
int64_t start = Position * samples ;
2006-02-02 19:17:54 +01:00
int rate = provider - > GetSampleRate ( ) ;
2006-01-16 22:02:54 +01:00
int pixBounds = rate / samples ;
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Seconds Boundaries " ) - > GetColour ( ) ) , 1 , wxDOT ) ) ;
2006-01-16 22:02:54 +01:00
if ( pixBounds > = 8 ) {
for ( int x = 0 ; x < w ; x + + ) {
if ( ( ( x * samples ) + start ) % rate < samples ) {
dc . DrawLine ( x , 0 , x , h ) ;
}
}
}
}
2008-01-14 02:18:24 +01:00
// Draw current frame
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Display/Draw/Video Position " ) - > GetBool ( ) ) {
2008-01-14 02:18:24 +01:00
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Play Cursor " ) - > GetColour ( ) ) ) ) ;
2008-01-14 02:18:24 +01:00
int x = GetXAtMS ( VFR_Output . GetTimeAtFrame ( VideoContext : : Get ( ) - > GetFrameN ( ) ) ) ;
dc . DrawLine ( x , 0 , x , h ) ;
}
}
2006-01-16 22:02:54 +01:00
// Draw keyframes
2007-04-07 04:39:18 +02:00
if ( drawKeyframes & & VideoContext : : Get ( ) - > KeyFramesLoaded ( ) ) {
DrawKeyframes ( dc ) ;
2006-01-16 22:02:54 +01:00
}
// Draw previous line
2007-04-13 03:29:05 +02:00
DrawInactiveLines ( dc ) ;
2006-01-16 22:02:54 +01:00
if ( hasSel ) {
// Draw boundaries
2007-01-06 05:19:00 +01:00
if ( true ) {
// Draw start boundary
2010-05-21 03:13:36 +02:00
int selWidth = OPT_GET ( " Audio/Line Boundaries Thickness " ) - > GetInt ( ) ;
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line boundary Start " ) - > GetColour ( ) ) ) ) ;
dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line boundary Start " ) - > GetColour ( ) ) ) ) ;
2007-01-06 05:19:00 +01:00
dc . DrawRectangle ( lineStart - selWidth / 2 + 1 , 0 , selWidth , h ) ;
wxPoint points1 [ 3 ] = { wxPoint ( lineStart , 0 ) , wxPoint ( lineStart + 10 , 0 ) , wxPoint ( lineStart , 10 ) } ;
wxPoint points2 [ 3 ] = { wxPoint ( lineStart , h - 1 ) , wxPoint ( lineStart + 10 , h - 1 ) , wxPoint ( lineStart , h - 11 ) } ;
dc . DrawPolygon ( 3 , points1 ) ;
dc . DrawPolygon ( 3 , points2 ) ;
// Draw end boundary
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line boundary End " ) - > GetColour ( ) ) ) ) ;
dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line boundary End " ) - > GetColour ( ) ) ) ) ;
2007-01-06 05:19:00 +01:00
dc . DrawRectangle ( lineEnd - selWidth / 2 + 1 , 0 , selWidth , h ) ;
wxPoint points3 [ 3 ] = { wxPoint ( lineEnd , 0 ) , wxPoint ( lineEnd - 10 , 0 ) , wxPoint ( lineEnd , 10 ) } ;
wxPoint points4 [ 3 ] = { wxPoint ( lineEnd , h - 1 ) , wxPoint ( lineEnd - 10 , h - 1 ) , wxPoint ( lineEnd , h - 11 ) } ;
dc . DrawPolygon ( 3 , points3 ) ;
dc . DrawPolygon ( 3 , points4 ) ;
}
2006-01-16 22:02:54 +01:00
// Draw karaoke
if ( hasKaraoke ) {
2006-02-20 08:12:01 +01:00
try {
// Prepare
2010-05-21 03:13:36 +02:00
wxPen curPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Syllable Boundaries " ) - > GetColour ( ) ) , 1 , wxDOT ) ;
2006-02-20 08:12:01 +01:00
dc . SetPen ( curPen ) ;
wxFont curFont ( 9 , wxFONTFAMILY_DEFAULT , wxFONTSTYLE_NORMAL , wxFONTWEIGHT_BOLD , false , _T ( " Verdana " ) , wxFONTENCODING_SYSTEM ) ;
dc . SetFont ( curFont ) ;
2010-05-21 03:13:36 +02:00
if ( ! spectrum ) dc . SetTextForeground ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Syllable Text " ) - > GetColour ( ) ) ) ;
2006-02-20 08:12:01 +01:00
else dc . SetTextForeground ( wxColour ( 255 , 255 , 255 ) ) ;
size_t karn = karaoke - > syllables . size ( ) ;
2007-08-31 16:11:35 +02:00
int64_t pos1 , pos2 ;
2006-02-20 08:12:01 +01:00
int len , curpos ;
wxCoord tw = 0 , th = 0 ;
2007-06-23 02:21:20 +02:00
AudioKaraokeSyllable * curSyl ;
2006-02-20 08:12:01 +01:00
wxString temptext ;
// Draw syllables
for ( size_t i = 0 ; i < karn ; i + + ) {
2006-01-16 22:02:54 +01:00
curSyl = & karaoke - > syllables . at ( i ) ;
2007-06-23 02:21:20 +02:00
len = curSyl - > duration * 10 ;
curpos = curSyl - > start_time * 10 ;
2006-01-16 22:02:54 +01:00
if ( len ! = - 1 ) {
pos1 = GetXAtMS ( curStartMS + curpos ) ;
pos2 = GetXAtMS ( curStartMS + len + curpos ) ;
dc . DrawLine ( pos2 , 0 , pos2 , h ) ;
2007-06-23 02:21:20 +02:00
temptext = curSyl - > text ;
2006-01-16 22:02:54 +01:00
temptext . Trim ( true ) ;
temptext . Trim ( false ) ;
GetTextExtent ( temptext , & tw , & th , NULL , NULL , & curFont ) ;
2007-01-07 07:36:10 +01:00
dc . DrawText ( temptext , ( pos1 + pos2 - tw ) / 2 , 4 ) ;
2006-01-16 22:02:54 +01:00
}
}
2006-02-20 08:12:01 +01:00
}
catch ( . . . ) {
2007-01-07 05:44:11 +01:00
// FIXME?
2006-01-16 22:02:54 +01:00
}
}
}
// Modified text
if ( NeedCommit ) {
2007-01-07 05:44:11 +01:00
dc . SetFont ( wxFont ( 9 , wxDEFAULT , wxFONTSTYLE_NORMAL , wxFONTWEIGHT_BOLD , false , _T ( " Verdana " ) ) ) ; // FIXME: hardcoded font name
2006-01-16 22:02:54 +01:00
dc . SetTextForeground ( wxColour ( 255 , 0 , 0 ) ) ;
if ( selStart < = selEnd ) {
dc . DrawText ( _T ( " Modified " ) , 4 , 4 ) ;
}
else {
dc . DrawText ( _T ( " Negative time " ) , 4 , 4 ) ;
}
}
2007-04-07 04:39:18 +02:00
// Draw timescale
if ( timelineHeight ) {
DrawTimescale ( dc ) ;
}
2006-01-16 22:02:54 +01:00
// Draw selection border
if ( hasFocus ) {
dc . SetPen ( * wxGREEN_PEN ) ;
dc . SetBrush ( * wxTRANSPARENT_BRUSH ) ;
dc . DrawRectangle ( 0 , 0 , w , h ) ;
}
2007-04-07 04:39:18 +02:00
// Done
2008-11-14 02:21:17 +01:00
needImageUpdate = false ;
2008-11-25 02:49:17 +01:00
needImageUpdateWeak = true ;
2007-04-07 04:39:18 +02:00
}
2009-08-01 04:32:26 +02:00
/// @brief Draw other lines than the current active
/// @param dc The DC to draw to.
/// Draws markers for inactive lines, eg. the previous line, per configuration.
2007-04-13 03:29:05 +02:00
void AudioDisplay : : DrawInactiveLines ( wxDC & dc ) {
// Check if there is anything to do
2010-05-21 03:13:36 +02:00
int shadeType = OPT_GET ( " Audio/Inactive Lines Display Mode " ) - > GetInt ( ) ;
2007-04-13 03:29:05 +02:00
if ( shadeType = = 0 ) return ;
// Spectrum?
bool spectrum = false ;
2010-05-21 03:13:36 +02:00
if ( provider & & OPT_GET ( " Audio/Spectrum " ) - > GetBool ( ) ) {
2007-04-13 03:29:05 +02:00
spectrum = true ;
}
// Set options
2010-05-21 03:13:36 +02:00
dc . SetBrush ( wxBrush ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line Boundary Inactive Line " ) - > GetColour ( ) ) ) ) ;
int selWidth = OPT_GET ( " Audio/Line Boundaries Thickness " ) - > GetInt ( ) ;
2007-04-13 03:29:05 +02:00
AssDialogue * shade ;
int shadeX1 , shadeX2 ;
int shadeFrom , shadeTo ;
// Only previous
if ( shadeType = = 1 ) {
shadeFrom = this - > line_n - 1 ;
shadeTo = shadeFrom + 1 ;
}
// All
else {
shadeFrom = 0 ;
shadeTo = grid - > GetRows ( ) ;
}
for ( int j = shadeFrom ; j < shadeTo ; j + + ) {
if ( j = = line_n ) continue ;
2007-07-28 15:59:32 +02:00
if ( j < 0 ) continue ;
2007-04-13 03:29:05 +02:00
shade = grid - > GetDialogue ( j ) ;
if ( shade ) {
// Get coordinates
shadeX1 = GetXAtMS ( shade - > Start . GetMS ( ) ) ;
shadeX2 = GetXAtMS ( shade - > End . GetMS ( ) ) ;
if ( shadeX2 < 0 | | shadeX1 > w ) continue ;
// Draw over waveform
if ( ! spectrum ) {
// Selection
int selX1 = MAX ( 0 , GetXAtMS ( curStartMS ) ) ;
int selX2 = MIN ( w , GetXAtMS ( curEndMS ) ) ;
// Get ranges (x1->x2, x3->x4).
int x1 = MAX ( 0 , shadeX1 ) ;
int x2 = MIN ( w , shadeX2 ) ;
int x3 = MAX ( x1 , selX2 ) ;
int x4 = MAX ( x2 , selX2 ) ;
// Clip first range
x1 = MIN ( x1 , selX1 ) ;
x2 = MIN ( x2 , selX1 ) ;
// Set pen and draw
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Waveform Inactive " ) - > GetColour ( ) ) ) ) ;
2007-04-13 03:29:05 +02:00
for ( int i = x1 ; i < x2 ; i + + ) dc . DrawLine ( i , peak [ i ] , i , min [ i ] - 1 ) ;
for ( int i = x3 ; i < x4 ; i + + ) dc . DrawLine ( i , peak [ i ] , i , min [ i ] - 1 ) ;
}
// Draw boundaries
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Line Boundary Inactive Line " ) - > GetColour ( ) ) ) ) ;
2007-04-13 03:29:05 +02:00
dc . DrawRectangle ( shadeX1 - selWidth / 2 + 1 , 0 , selWidth , h ) ;
dc . DrawRectangle ( shadeX2 - selWidth / 2 + 1 , 0 , selWidth , h ) ;
}
}
}
2009-08-01 04:32:26 +02:00
/// @brief Draw keyframe markers
/// @param dc The DC to draw to.
2007-04-07 04:39:18 +02:00
void AudioDisplay : : DrawKeyframes ( wxDC & dc ) {
wxArrayInt KeyFrames = VideoContext : : Get ( ) - > GetKeyFrames ( ) ;
int nKeys = ( int ) KeyFrames . Count ( ) ;
dc . SetPen ( wxPen ( wxColour ( 255 , 0 , 255 ) , 1 ) ) ;
// Get min and max frames to care about
int minFrame = VFR_Output . GetFrameAtTime ( GetMSAtX ( 0 ) , true ) ;
int maxFrame = VFR_Output . GetFrameAtTime ( GetMSAtX ( w ) , true ) ;
// Scan list
for ( int i = 0 ; i < nKeys ; i + + ) {
int cur = KeyFrames [ i ] ;
if ( cur > = minFrame & & cur < = maxFrame ) {
int x = GetXAtMS ( VFR_Output . GetTimeAtFrame ( cur , true ) ) ;
dc . DrawLine ( x , 0 , x , h ) ;
}
else if ( cur > maxFrame ) break ;
}
}
2006-03-06 01:45:24 +01:00
2009-08-01 04:32:26 +02:00
/// @brief Draw timescale at bottom of audio display
/// @param dc The DC to draw to.
2007-04-07 04:39:18 +02:00
void AudioDisplay : : DrawTimescale ( wxDC & dc ) {
// Set size
2010-05-21 03:13:36 +02:00
int timelineHeight = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2007-04-07 04:39:18 +02:00
// Set colours
dc . SetBrush ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_BTNFACE ) ) ;
dc . SetPen ( * wxTRANSPARENT_PEN ) ;
dc . DrawRectangle ( 0 , h , w , timelineHeight ) ;
dc . SetPen ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_3DLIGHT ) ) ;
dc . DrawLine ( 0 , h , w , h ) ;
dc . SetPen ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_3DHIGHLIGHT ) ) ;
dc . DrawLine ( 0 , h + 1 , w , h + 1 ) ;
dc . SetPen ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_BTNTEXT ) ) ;
dc . SetTextForeground ( wxSystemSettings : : GetColour ( wxSYS_COLOUR_BTNTEXT ) ) ;
wxFont scaleFont ;
scaleFont . SetFaceName ( _T ( " Tahoma " ) ) ; // FIXME: hardcoded font name
scaleFont . SetPointSize ( 8 ) ;
dc . SetFont ( scaleFont ) ;
// Timescale ticks
2007-08-31 16:11:35 +02:00
int64_t start = Position * samples ;
2007-04-07 04:39:18 +02:00
int rate = provider - > GetSampleRate ( ) ;
for ( int i = 1 ; i < 32 ; i * = 2 ) {
int pixBounds = rate / ( samples * 4 / i ) ;
if ( pixBounds > = 8 ) {
for ( int x = 0 ; x < w ; x + + ) {
2007-08-31 16:11:35 +02:00
int64_t pos = ( x * samples ) + start ;
2007-04-07 04:39:18 +02:00
// Second boundary
if ( pos % rate < samples ) {
dc . DrawLine ( x , h + 2 , x , h + 8 ) ;
// Draw text
wxCoord textW , textH ;
int hr = 0 ;
int m = 0 ;
int s = pos / rate ;
while ( s > = 3600 ) {
s - = 3600 ;
hr + + ;
2007-01-06 07:14:35 +01:00
}
2007-04-07 04:39:18 +02:00
while ( s > = 60 ) {
s - = 60 ;
m + + ;
}
wxString text ;
if ( hr ) text = wxString : : Format ( _T ( " %i:%02i:%02i " ) , hr , m , s ) ;
else if ( m ) text = wxString : : Format ( _T ( " %i:%02i " ) , m , s ) ;
else text = wxString : : Format ( _T ( " %i " ) , s ) ;
dc . GetTextExtent ( text , & textW , & textH , NULL , NULL , & scaleFont ) ;
dc . DrawText ( text , MAX ( 0 , x - textW / 2 ) + 1 , h + 8 ) ;
}
// Other
else if ( pos % ( rate / 4 * i ) < samples ) {
dc . DrawLine ( x , h + 2 , x , h + 5 ) ;
2006-03-06 01:45:24 +01:00
}
}
2007-04-07 04:39:18 +02:00
break ;
2006-03-06 01:45:24 +01:00
}
}
2006-01-16 22:02:54 +01:00
}
2009-08-01 04:32:26 +02:00
/// @brief Draw audio waveform
/// @param dc The DC to draw to.
/// @param weak False if the visible portion of the display has changed.
2006-01-16 22:02:54 +01:00
void AudioDisplay : : DrawWaveform ( wxDC & dc , bool weak ) {
// Prepare Waveform
if ( ! weak | | peak = = NULL | | min = = NULL ) {
2009-05-22 02:05:25 +02:00
if ( peak ) delete [ ] peak ;
if ( min ) delete [ ] min ;
2006-01-16 22:02:54 +01:00
peak = new int [ w ] ;
min = new int [ w ] ;
}
// Get waveform
if ( ! weak ) {
provider - > GetWaveForm ( min , peak , Position * samples , w , h , samples , scale ) ;
}
// Draw pre-selection
if ( ! hasSel ) selStartCap = w ;
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Waveform " ) - > GetColour ( ) ) ) ) ;
2007-08-31 16:11:35 +02:00
for ( int64_t i = 0 ; i < selStartCap ; i + + ) {
2006-01-16 22:02:54 +01:00
dc . DrawLine ( i , peak [ i ] , i , min [ i ] - 1 ) ;
}
if ( hasSel ) {
// Draw selection
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Display/Draw/Selection Background " ) - > GetBool ( ) ) {
if ( NeedCommit & & ! karaoke - > enabled ) dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Waveform Modified " ) - > GetColour ( ) ) ) ) ;
else dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Waveform Selected " ) - > GetColour ( ) ) ) ) ;
2006-01-16 22:02:54 +01:00
}
2007-08-31 16:11:35 +02:00
for ( int64_t i = selStartCap ; i < selEndCap ; i + + ) {
2006-01-16 22:02:54 +01:00
dc . DrawLine ( i , peak [ i ] , i , min [ i ] - 1 ) ;
}
// Draw post-selection
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Waveform " ) - > GetColour ( ) ) ) ) ;
2007-08-31 16:11:35 +02:00
for ( int64_t i = selEndCap ; i < w ; i + + ) {
2006-01-16 22:02:54 +01:00
dc . DrawLine ( i , peak [ i ] , i , min [ i ] - 1 ) ;
}
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Draw spectrum analyzer
2009-08-01 04:32:26 +02:00
/// @param finaldc The DC to draw to.
/// @param weak False if the visible portion of the display has changed.
/// @bug Slow when non-weak and the selection has to be drawn, see:
2009-08-01 05:40:47 +02:00
/// @ticket{951} Spectrum view scrolls/updates considerably slower when selection is visible
2006-01-16 22:02:54 +01:00
void AudioDisplay : : DrawSpectrum ( wxDC & finaldc , bool weak ) {
if ( ! weak | | ! spectrumDisplay | | spectrumDisplay - > GetWidth ( ) ! = w | | spectrumDisplay - > GetHeight ( ) ! = h ) {
2007-01-06 22:56:25 +01:00
if ( spectrumDisplay ) {
delete spectrumDisplay ;
2007-01-07 05:44:11 +01:00
delete spectrumDisplaySelected ;
2007-01-06 22:56:25 +01:00
spectrumDisplay = 0 ;
2007-01-07 05:44:11 +01:00
spectrumDisplaySelected = 0 ;
2007-01-06 22:56:25 +01:00
}
2006-01-16 22:02:54 +01:00
weak = false ;
}
if ( ! weak ) {
2007-01-07 05:44:11 +01:00
if ( ! spectrumRenderer )
2007-06-24 22:46:52 +02:00
spectrumRenderer = new AudioSpectrum ( provider ) ;
2006-01-16 22:02:54 +01:00
2007-01-07 05:44:11 +01:00
spectrumRenderer - > SetScaling ( scale ) ;
2008-01-22 21:36:07 +01:00
unsigned char * img = ( unsigned char * ) malloc ( h * w * 3 ) ; // wxImage requires using malloc
2007-01-07 05:44:11 +01:00
// Use a slightly slower, but simple way
// Always draw the spectrum for the entire width
// Hack: without those divs by 2 the display is horizontally compressed
spectrumRenderer - > RenderRange ( Position * samples , ( Position + w ) * samples , false , img , 0 , w , w , h ) ;
2006-08-27 21:54:51 +02:00
2007-01-07 05:44:11 +01:00
// The spectrum bitmap will have been deleted above already, so just make a new one
wxImage imgobj ( w , h , img , false ) ;
spectrumDisplay = new wxBitmap ( imgobj ) ;
}
2006-01-16 22:02:54 +01:00
2007-01-07 05:52:33 +01:00
if ( hasSel & & selStartCap < selEndCap & & ! spectrumDisplaySelected ) {
// There is a visible selection and we don't have a rendered one
// This should be done regardless whether we're "weak" or not
// Assume a few things were already set up when things were first rendered though
unsigned char * img = ( unsigned char * ) malloc ( h * w * 3 ) ;
spectrumRenderer - > RenderRange ( Position * samples , ( Position + w ) * samples , true , img , 0 , w , w , h ) ;
wxImage imgobj ( w , h , img , false ) ;
spectrumDisplaySelected = new wxBitmap ( imgobj ) ;
2006-01-16 22:02:54 +01:00
}
// Draw
wxMemoryDC dc ;
dc . SelectObject ( * spectrumDisplay ) ;
finaldc . Blit ( 0 , 0 , w , h , & dc , 0 , 0 ) ;
2007-01-07 05:44:11 +01:00
if ( hasSel & & spectrumDisplaySelected & & selStartCap < selEndCap ) {
dc . SelectObject ( * spectrumDisplaySelected ) ;
2007-01-07 07:36:10 +01:00
finaldc . Blit ( selStartCap , 0 , selEndCap - selStartCap , h , & dc , selStartCap , 0 ) ;
2007-01-07 05:44:11 +01:00
}
}
2006-01-16 22:02:54 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get selection position
/// @param selStart
/// @param selEnd
/// @param cap
2007-08-31 16:11:35 +02:00
void AudioDisplay : : GetDialoguePos ( int64_t & selStart , int64_t & selEnd , bool cap ) {
2006-01-16 22:02:54 +01:00
selStart = GetXAtMS ( curStartMS ) ;
selEnd = GetXAtMS ( curEndMS ) ;
if ( cap ) {
if ( selStart < 0 ) selStart = 0 ;
if ( selEnd < 0 ) selEnd = 0 ;
if ( selStart > = w ) selStart = w - 1 ;
if ( selEnd > = w ) selEnd = w - 1 ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get karaoke position
/// @param karStart
/// @param karEnd
/// @param cap
2007-08-31 16:11:35 +02:00
void AudioDisplay : : GetKaraokePos ( int64_t & karStart , int64_t & karEnd , bool cap ) {
2006-02-20 08:12:01 +01:00
try {
// Wrap around
2006-08-28 00:29:14 +02:00
int nsyls = ( int ) karaoke - > syllables . size ( ) ;
2006-02-20 08:12:01 +01:00
if ( karaoke - > curSyllable = = - 1 ) {
karaoke - > SetSyllable ( nsyls - 1 ) ;
}
if ( karaoke - > curSyllable > = nsyls ) karaoke - > curSyllable = nsyls - 1 ;
2006-01-16 22:02:54 +01:00
2006-02-20 08:12:01 +01:00
// Get positions
2007-06-23 02:21:20 +02:00
int pos = karaoke - > syllables . at ( karaoke - > curSyllable ) . start_time ;
int len = karaoke - > syllables . at ( karaoke - > curSyllable ) . duration ;
2006-02-20 08:12:01 +01:00
karStart = GetXAtMS ( curStartMS + pos * 10 ) ;
karEnd = GetXAtMS ( curStartMS + pos * 10 + len * 10 ) ;
// Cap
if ( cap ) {
if ( karStart < 0 ) karStart = 0 ;
if ( karEnd < 0 ) karEnd = 0 ;
if ( karStart > = w ) karStart = w - 1 ;
if ( karEnd > = w ) karEnd = w - 1 ;
}
}
catch ( . . . ) {
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : Update ( ) {
if ( blockUpdate ) return ;
if ( loaded ) {
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Auto/Scroll " ) - > GetBool ( ) )
2006-02-02 19:24:58 +01:00
MakeDialogueVisible ( ) ;
else
2006-01-16 22:02:54 +01:00
UpdateImage ( true ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Recreate the image
2007-01-06 07:14:35 +01:00
void AudioDisplay : : RecreateImage ( ) {
GetClientSize ( & w , & h ) ;
2010-05-21 03:13:36 +02:00
h - = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2007-01-06 07:14:35 +01:00
delete origImage ;
origImage = NULL ;
UpdateImage ( false ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Make dialogue visible
/// @param force
2006-01-16 22:02:54 +01:00
void AudioDisplay : : MakeDialogueVisible ( bool force ) {
// Variables
2009-05-15 00:12:05 +02:00
int startShow = 0 , endShow = 0 ;
2007-04-10 02:51:03 +02:00
if ( karaoke - > enabled ) {
2009-05-15 00:12:05 +02:00
// In karaoke mode the syllable and as much as possible towards the end of the line should be shown
int dummy = 0 ;
GetTimesSelection ( startShow , dummy ) ;
GetTimesDialogue ( dummy , endShow ) ;
2007-04-10 02:51:03 +02:00
} else {
2009-05-15 00:12:05 +02:00
GetTimesSelection ( startShow , endShow ) ;
2007-04-10 02:51:03 +02:00
}
2009-05-15 00:12:05 +02:00
int startPos = GetSampleAtMS ( startShow ) ;
int endPos = GetSampleAtMS ( endShow ) ;
int startX = GetXAtMS ( startShow ) ;
int endX = GetXAtMS ( endShow ) ;
2006-01-16 22:02:54 +01:00
if ( force | | startX < 50 | | endX > w - 50 ) {
2009-05-15 00:12:05 +02:00
if ( startX < 50 | | endX - startX > = w ) {
2007-04-10 02:51:03 +02:00
// Make sure the left edge of the selection is at least 50 pixels from the edge of the display
UpdatePosition ( startPos - 50 * samples , true ) ;
} else {
// Otherwise center the selection in display
UpdatePosition ( ( startPos + endPos - w * samples ) / 2 , true ) ;
}
2006-01-16 22:02:54 +01:00
}
// Update
UpdateImage ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Set position
/// @param pos
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetPosition ( int pos ) {
Position = pos ;
PositionSample = pos * samples ;
UpdateImage ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update position
/// @param pos
/// @param IsSample
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : UpdatePosition ( int pos , bool IsSample ) {
// Safeguards
2007-08-20 20:09:18 +02:00
if ( ! provider ) return ;
2006-01-16 22:02:54 +01:00
if ( IsSample ) pos / = samples ;
int len = provider - > GetNumSamples ( ) / samples ;
if ( pos < 0 ) pos = 0 ;
if ( pos > = len ) pos = len - 1 ;
// Set
Position = pos ;
PositionSample = pos * samples ;
UpdateScrollbar ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Note: aka Horizontal Zoom Set samples in percentage
/// @param percent
/// @param update
/// @param pivot
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetSamplesPercent ( int percent , bool update , float pivot ) {
// Calculate
if ( percent < 1 ) percent = 1 ;
if ( percent > 100 ) percent = 100 ;
if ( samplesPercent = = percent ) return ;
samplesPercent = percent ;
// Update
if ( update ) {
// Center scroll
int oldSamples = samples ;
2006-02-25 01:11:54 +01:00
UpdateSamples ( ) ;
2007-08-31 16:11:35 +02:00
PositionSample + = int64_t ( ( oldSamples - samples ) * w * pivot ) ;
2006-01-16 22:02:54 +01:00
if ( PositionSample < 0 ) PositionSample = 0 ;
// Update
2006-02-25 01:11:54 +01:00
UpdateSamples ( ) ;
2006-01-16 22:02:54 +01:00
UpdateScrollbar ( ) ;
UpdateImage ( ) ;
2006-02-25 01:11:54 +01:00
Refresh ( false ) ;
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update samples
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : UpdateSamples ( ) {
// Set samples
2006-07-04 23:59:30 +02:00
if ( ! provider ) return ;
2008-01-25 21:53:12 +01:00
if ( w ) {
int64_t totalSamples = provider - > GetNumSamples ( ) ;
int total = totalSamples / w ;
int max = 5760000 / w ; // 2 minutes at 48 kHz maximum
if ( total > max ) total = max ;
int min = 8 ;
if ( total < min ) total = min ;
int range = total - min ;
samples = int ( range * pow ( samplesPercent / 100.0 , 3 ) + min ) ;
// Set position
int length = w * samples ;
if ( PositionSample + length > totalSamples ) {
PositionSample = totalSamples - length ;
if ( PositionSample < 0 ) PositionSample = 0 ;
if ( samples ) Position = PositionSample / samples ;
}
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Set scale
/// @param _scale
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetScale ( float _scale ) {
if ( scale = = _scale ) return ;
scale = _scale ;
UpdateImage ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Load from file
/// @param file
/// @return
2008-03-08 19:04:51 +01:00
void AudioDisplay : : SetFile ( wxString file ) {
2006-02-25 08:41:18 +01:00
// Unload
2007-08-17 01:17:54 +02:00
if ( file . IsEmpty ( ) ) try {
2007-08-17 00:45:29 +02:00
try {
if ( player ) player - > CloseStream ( ) ;
}
catch ( const wxChar * e ) {
wxLogError ( e ) ;
}
2006-02-25 08:41:18 +01:00
delete provider ;
delete player ;
2007-01-07 05:44:11 +01:00
delete spectrumRenderer ;
2006-01-16 22:02:54 +01:00
provider = NULL ;
2006-02-25 08:41:18 +01:00
player = NULL ;
2007-01-07 05:44:11 +01:00
spectrumRenderer = NULL ;
2007-08-17 00:45:29 +02:00
try {
Reset ( ) ;
}
catch ( const wxChar * e ) {
wxLogError ( e ) ;
}
2006-02-02 19:17:54 +01:00
loaded = false ;
2006-07-04 23:59:30 +02:00
temporary = false ;
2007-06-21 00:23:55 +02:00
StandardPaths : : SetPathValue ( _T ( " ?audio " ) , _T ( " " ) ) ;
2006-01-16 22:02:54 +01:00
}
2007-08-17 01:17:54 +02:00
catch ( wxString e ) {
wxLogError ( e ) ;
}
catch ( const wxChar * e ) {
wxLogError ( e ) ;
}
catch ( . . . ) {
wxLogError ( _T ( " Unknown error unloading audio " ) ) ;
}
2006-02-25 08:41:18 +01:00
// Load
2006-01-16 22:02:54 +01:00
else {
SetFile ( _T ( " " ) ) ;
try {
2006-02-25 08:41:18 +01:00
// Get provider
2007-07-23 17:19:48 +02:00
bool is_dummy = false ;
# ifdef _DEBUG
if ( file = = _T ( " ?dummy " ) ) {
is_dummy = true ;
provider = new DummyAudioProvider ( 150 * 60 * 1000 , false ) ; // 150 minutes non-noise
} else if ( file = = _T ( " ?noise " ) ) {
is_dummy = true ;
provider = new DummyAudioProvider ( 150 * 60 * 1000 , true ) ; // 150 minutes noise
} else {
2008-03-07 03:32:29 +01:00
provider = AudioProviderFactoryManager : : GetAudioProvider ( file ) ;
2007-07-23 17:19:48 +02:00
}
# else
2008-03-07 03:32:29 +01:00
provider = AudioProviderFactoryManager : : GetAudioProvider ( file ) ;
2007-07-23 17:19:48 +02:00
# endif
2006-01-16 22:02:54 +01:00
2006-02-25 08:41:18 +01:00
// Get player
2008-03-07 03:32:29 +01:00
player = AudioPlayerFactoryManager : : GetAudioPlayer ( ) ;
2006-02-25 08:41:18 +01:00
player - > SetDisplayTimer ( & UpdateTimer ) ;
player - > SetProvider ( provider ) ;
player - > OpenStream ( ) ;
2006-02-02 19:17:54 +01:00
loaded = true ;
2006-01-16 22:02:54 +01:00
// Add to recent
2007-07-23 17:19:48 +02:00
if ( ! is_dummy ) {
2010-05-21 03:13:36 +02:00
AegisubApp : : Get ( ) - > mru - > Add ( " Audio " , STD_STR ( file ) ) ;
2007-07-23 17:19:48 +02:00
wxFileName fn ( file ) ;
StandardPaths : : SetPathValue ( _T ( " ?audio " ) , fn . GetPath ( ) ) ;
}
2006-02-02 19:17:54 +01:00
// Update
UpdateImage ( ) ;
2006-01-16 22:02:54 +01:00
}
2007-08-17 00:45:29 +02:00
catch ( const wxChar * e ) {
2007-08-17 01:17:54 +02:00
if ( player ) { delete player ; player = 0 ; }
if ( provider ) { delete provider ; provider = 0 ; }
2007-08-17 00:45:29 +02:00
wxLogError ( e ) ;
}
2006-01-16 22:02:54 +01:00
catch ( wxString & err ) {
2007-08-17 01:17:54 +02:00
if ( player ) { delete player ; player = 0 ; }
if ( provider ) { delete provider ; provider = 0 ; }
2006-01-16 22:02:54 +01:00
wxMessageBox ( err , _T ( " Error loading audio " ) , wxICON_ERROR | wxOK ) ;
}
2007-08-17 01:17:54 +02:00
catch ( . . . ) {
if ( player ) { delete player ; player = 0 ; }
if ( provider ) { delete provider ; provider = 0 ; }
wxLogError ( _T ( " Unknown error loading audio " ) ) ;
}
2006-01-16 22:02:54 +01:00
}
2007-07-09 13:52:28 +02:00
if ( ! loaded ) return ;
2006-01-16 22:02:54 +01:00
2006-02-02 19:17:54 +01:00
assert ( loaded = = ( provider ! = NULL ) ) ;
2006-01-16 22:02:54 +01:00
// Set default selection
int n = grid - > editBox - > linen ;
SetDialogue ( grid , grid - > GetDialogue ( n ) , n ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Load from video
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetFromVideo ( ) {
2007-01-21 07:30:19 +01:00
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
wxString extension = VideoContext : : Get ( ) - > videoName . Right ( 4 ) ;
2006-01-16 22:02:54 +01:00
extension . LowerCase ( ) ;
2007-06-20 04:18:55 +02:00
if ( extension ! = _T ( " .d2v " ) ) SetFile ( VideoContext : : Get ( ) - > videoName ) ;
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Reload audio
2007-04-10 04:55:23 +02:00
void AudioDisplay : : Reload ( ) {
if ( provider ) SetFile ( provider - > GetFilename ( ) ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update scrollbar
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : UpdateScrollbar ( ) {
2006-07-04 23:59:30 +02:00
if ( ! provider ) return ;
2006-01-16 22:02:54 +01:00
int page = w / 12 ;
int len = provider - > GetNumSamples ( ) / samples / 12 ;
Position = PositionSample / samples ;
2007-04-04 22:42:44 +02:00
ScrollBar - > SetScrollbar ( Position / 12 , page , len , int ( page * 0.7 ) , true ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Gets the sample number at the x coordinate
/// @param x
/// @return
2007-08-31 16:11:35 +02:00
int64_t AudioDisplay : : GetSampleAtX ( int x ) {
2006-01-16 22:02:54 +01:00
return ( x + Position ) * samples ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Gets the x coordinate corresponding to sample
/// @param n
/// @return
2007-08-31 16:11:35 +02:00
int AudioDisplay : : GetXAtSample ( int64_t n ) {
2007-06-23 04:43:42 +02:00
return samples ? ( n / samples ) - Position : 0 ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get MS from X
/// @param x
/// @return
2007-08-31 16:11:35 +02:00
int AudioDisplay : : GetMSAtX ( int64_t x ) {
2006-02-02 19:17:54 +01:00
return ( PositionSample + ( x * samples ) ) * 1000 / provider - > GetSampleRate ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get X from MS
/// @param ms
/// @return
2007-08-31 16:11:35 +02:00
int AudioDisplay : : GetXAtMS ( int64_t ms ) {
2006-02-02 19:17:54 +01:00
return ( ( ms * provider - > GetSampleRate ( ) / 1000 ) - PositionSample ) / samples ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get MS At sample
/// @param x
/// @return
2007-08-31 16:11:35 +02:00
int AudioDisplay : : GetMSAtSample ( int64_t x ) {
2006-02-02 19:17:54 +01:00
return x * 1000 / provider - > GetSampleRate ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get Sample at MS
/// @param ms
/// @return
2007-08-31 16:11:35 +02:00
int64_t AudioDisplay : : GetSampleAtMS ( int64_t ms ) {
2006-02-02 19:17:54 +01:00
return ms * provider - > GetSampleRate ( ) / 1000 ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Play
/// @param start
/// @param end
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : Play ( int start , int end ) {
2007-03-18 02:20:25 +01:00
Stop ( ) ;
2006-01-16 22:02:54 +01:00
// Check provider
2006-07-01 08:32:11 +02:00
if ( ! provider ) {
2010-01-06 09:02:15 +01:00
return ;
2006-07-01 08:32:11 +02:00
}
2006-01-16 22:02:54 +01:00
// Set defaults
2009-05-15 17:23:34 +02:00
playingToEnd = end < 0 ;
2007-08-31 16:11:35 +02:00
int64_t num_samples = provider - > GetNumSamples ( ) ;
2006-01-16 22:02:54 +01:00
start = GetSampleAtMS ( start ) ;
if ( end ! = - 1 ) end = GetSampleAtMS ( end ) ;
else end = num_samples - 1 ;
// Sanity checking
if ( start < 0 ) start = 0 ;
if ( start > = num_samples ) start = num_samples - 1 ;
if ( end > = num_samples ) end = num_samples - 1 ;
if ( end < start ) end = start ;
2009-06-06 04:32:31 +02:00
// Redraw the image to avoid any junk left over from mouse movements etc
// See issue #598
UpdateImage ( true ) ;
2006-01-16 22:02:54 +01:00
// Call play
2006-02-25 08:41:18 +01:00
player - > Play ( start , end - start ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Stop
2006-01-16 22:02:54 +01:00
void AudioDisplay : : Stop ( ) {
2007-01-21 18:01:22 +01:00
if ( VideoContext : : Get ( ) - > IsPlaying ( ) ) VideoContext : : Get ( ) - > Stop ( ) ;
2007-03-18 02:20:25 +01:00
if ( player ) player - > Stop ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get samples of dialogue
/// @param start
/// @param end
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : GetTimesDialogue ( int & start , int & end ) {
if ( ! dialogue ) {
start = 0 ;
end = 0 ;
return ;
}
start = dialogue - > Start . GetMS ( ) ;
end = dialogue - > End . GetMS ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get samples of selection
/// @param start
/// @param end
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : GetTimesSelection ( int & start , int & end ) {
2006-02-20 08:12:01 +01:00
start = 0 ;
end = 0 ;
if ( ! dialogue ) return ;
2006-01-16 22:02:54 +01:00
2006-02-20 08:12:01 +01:00
try {
if ( karaoke - > enabled ) {
2007-06-23 02:21:20 +02:00
int pos = karaoke - > syllables . at ( karaoke - > curSyllable ) . start_time ;
int len = karaoke - > syllables . at ( karaoke - > curSyllable ) . duration ;
2006-02-20 08:12:01 +01:00
start = curStartMS + pos * 10 ;
end = curStartMS + pos * 10 + len * 10 ;
}
else {
start = curStartMS ;
end = curEndMS ;
}
2006-01-16 22:02:54 +01:00
}
2006-02-20 08:12:01 +01:00
catch ( . . . ) { }
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Set the current selection
/// @param start
/// @param end
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetSelection ( int start , int end ) {
curStartMS = start ;
curEndMS = end ;
Update ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Set dialogue
/// @param _grid
/// @param diag
/// @param n
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : SetDialogue ( SubtitlesGrid * _grid , AssDialogue * diag , int n ) {
// Actual parameters
if ( _grid ) {
// Set variables
grid = _grid ;
line_n = n ;
dialogue = diag ;
// Set flags
diagUpdated = false ;
NeedCommit = false ;
// Set times
2010-05-21 03:13:36 +02:00
if ( dialogue & & ! dontReadTimes & & OPT_GET ( " Audio/Grab Times on Select " ) - > GetBool ( ) ) {
2007-04-09 20:25:58 +02:00
int s = dialogue - > Start . GetMS ( ) ;
int e = dialogue - > End . GetMS ( ) ;
// Never do it for 0:00:00.00->0:00:00.00 lines
if ( s ! = 0 | | e ! = 0 ) {
curStartMS = s ;
curEndMS = e ;
}
2006-01-16 22:02:54 +01:00
}
}
// Read karaoke data
if ( dialogue & & karaoke - > enabled ) {
NeedCommit = karaoke - > LoadFromDialogue ( dialogue ) ;
// Reset karaoke pos
2006-08-28 00:29:14 +02:00
if ( karaoke - > curSyllable = = - 1 ) karaoke - > SetSyllable ( ( int ) karaoke - > syllables . size ( ) - 1 ) ;
2006-01-16 22:02:54 +01:00
else karaoke - > SetSyllable ( 0 ) ;
}
// Update
Update ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Commit changes
/// @param nextLine
/// @return
2007-01-06 00:43:24 +01:00
void AudioDisplay : : CommitChanges ( bool nextLine ) {
2006-07-04 23:59:30 +02:00
// Loaded?
if ( ! loaded ) return ;
2007-01-06 04:40:58 +01:00
// Check validity
2009-04-26 03:02:23 +02:00
bool textNeedsCommit = grid - > GetDialogue ( line_n ) - > Text ! = grid - > editBox - > TextEdit - > GetText ( ) ;
bool timeNeedsCommit = grid - > GetDialogue ( line_n ) - > Start . GetMS ( ) ! = curStartMS | | grid - > GetDialogue ( line_n ) - > End . GetMS ( ) ! = curEndMS ;
if ( timeNeedsCommit | | textNeedsCommit ) NeedCommit = true ;
2007-01-06 04:40:58 +01:00
bool wasKaraSplitting = false ;
bool validCommit = true ;
2007-06-23 00:50:02 +02:00
if ( ! karaoke - > enabled & & ! karaoke - > splitting ) {
2007-01-06 04:40:58 +01:00
if ( ! NeedCommit | | curEndMS < curStartMS ) validCommit = false ;
2006-01-16 22:02:54 +01:00
}
// Update karaoke
2007-06-23 00:50:02 +02:00
int karaSelStart = 0 , karaSelEnd = - 1 ;
2006-01-16 22:02:54 +01:00
if ( karaoke - > enabled ) {
2007-06-23 00:50:02 +02:00
wasKaraSplitting = karaoke - > splitting ;
2006-01-16 22:02:54 +01:00
karaoke - > Commit ( ) ;
2007-06-23 00:50:02 +02:00
// Get karaoke selection
karaSelStart = karaoke - > syllables . size ( ) ;
for ( size_t k = 0 ; k < karaoke - > syllables . size ( ) ; + + k ) {
if ( karaoke - > syllables [ k ] . selected ) {
if ( ( signed ) k < karaSelStart ) karaSelStart = k ;
if ( ( signed ) k > karaSelEnd ) karaSelEnd = k ;
}
}
2006-01-16 22:02:54 +01:00
}
2007-01-06 04:40:58 +01:00
2009-04-26 03:02:23 +02:00
// Get selected rows
wxArrayInt sel = grid - > GetSelection ( ) ;
2007-01-06 04:40:58 +01:00
// Commit ok?
if ( validCommit ) {
// Reset flags
diagUpdated = false ;
NeedCommit = false ;
2006-01-16 22:02:54 +01:00
2007-01-06 04:40:58 +01:00
// Update dialogues
blockUpdate = true ;
AssDialogue * curDiag ;
2009-04-26 03:02:23 +02:00
for ( size_t i = 0 ; i < sel . GetCount ( ) ; i + + ) {
if ( grid - > IsInSelection ( line_n ) ) curDiag = grid - > GetDialogue ( sel [ i ] ) ;
else curDiag = grid - > GetDialogue ( line_n ) ;
if ( timeNeedsCommit ) {
curDiag - > Start . SetMS ( curStartMS ) ;
curDiag - > End . SetMS ( curEndMS ) ;
2007-01-06 04:40:58 +01:00
}
2008-06-21 19:25:00 +02:00
if ( ! karaoke - > enabled & & textNeedsCommit ) {
2007-01-10 02:36:05 +01:00
// If user was editing karaoke stuff, that should take precedence of manual changes in the editbox,
2007-06-23 00:50:02 +02:00
// so only update from editbox when not in kara mode
2007-01-10 02:36:05 +01:00
curDiag - > Text = grid - > editBox - > TextEdit - > GetText ( ) ;
2007-06-20 04:18:55 +02:00
}
2007-01-06 04:40:58 +01:00
curDiag - > UpdateData ( ) ;
2009-04-26 03:02:23 +02:00
if ( ! grid - > IsInSelection ( line_n ) ) break ;
2006-02-20 23:32:20 +01:00
}
2007-01-08 04:05:26 +01:00
// Update edit box
grid - > editBox - > StartTime - > Update ( ) ;
grid - > editBox - > EndTime - > Update ( ) ;
grid - > editBox - > Duration - > Update ( ) ;
2007-01-06 04:40:58 +01:00
// Update grid
grid - > editBox - > Update ( ! karaoke - > enabled ) ;
2007-01-26 01:47:42 +01:00
grid - > ass - > FlagAsModified ( _T ( " " ) ) ;
2007-01-06 04:40:58 +01:00
grid - > CommitChanges ( ) ;
2007-06-23 00:50:02 +02:00
karaoke - > SetSelection ( karaSelStart , karaSelEnd ) ;
2007-01-06 04:40:58 +01:00
blockUpdate = false ;
2006-02-20 23:32:20 +01:00
}
2007-06-20 04:18:55 +02:00
// Next line (ugh what a condition, can this be simplified?)
2010-05-21 03:13:36 +02:00
if ( nextLine & & ! karaoke - > enabled & & OPT_GET ( " Audio/Next Line on Commit " ) - > GetBool ( ) & & ! wasKaraSplitting ) {
2006-12-18 21:13:23 +01:00
// Insert a line if it doesn't exist
int nrows = grid - > GetRows ( ) ;
if ( nrows = = line_n + 1 ) {
AssDialogue * def = new AssDialogue ;
def - > Start = grid - > GetDialogue ( line_n ) - > End ;
def - > End = grid - > GetDialogue ( line_n ) - > End ;
2010-05-21 03:13:36 +02:00
def - > End . SetMS ( def - > End . GetMS ( ) + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-12-18 21:13:23 +01:00
def - > Style = grid - > GetDialogue ( line_n ) - > Style ;
grid - > InsertLine ( def , line_n , true ) ;
2009-04-26 03:02:23 +02:00
curStartMS = curEndMS ;
2010-05-21 03:13:36 +02:00
curEndMS = curStartMS + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ;
2006-12-18 21:13:23 +01:00
}
2009-04-26 03:02:23 +02:00
else if ( grid - > GetDialogue ( line_n + 1 ) - > Start . GetMS ( ) = = 0 & & grid - > GetDialogue ( line_n + 1 ) - > End . GetMS ( ) = = 0 ) {
curStartMS = curEndMS ;
2010-05-21 03:13:36 +02:00
curEndMS = curStartMS + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ;
2009-04-26 03:02:23 +02:00
}
else {
curStartMS = grid - > GetDialogue ( line_n + 1 ) - > Start . GetMS ( ) ;
curEndMS = grid - > GetDialogue ( line_n + 1 ) - > End . GetMS ( ) ;
}
2006-12-18 21:13:23 +01:00
// Go to next
2006-01-16 22:02:54 +01:00
dontReadTimes = true ;
2009-04-26 03:02:23 +02:00
ChangeLine ( 1 , sel . GetCount ( ) > 1 ? true : false ) ;
2006-01-16 22:02:54 +01:00
dontReadTimes = false ;
}
Update ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Add lead
/// @param in
/// @param out
2006-01-16 22:02:54 +01:00
void AudioDisplay : : AddLead ( bool in , bool out ) {
// Lead in
if ( in ) {
2010-05-21 03:13:36 +02:00
curStartMS - = OPT_GET ( " Audio/Lead/IN " ) - > GetInt ( ) ;
2006-01-16 22:02:54 +01:00
if ( curStartMS < 0 ) curStartMS = 0 ;
}
// Lead out
if ( out ) {
2010-05-21 03:13:36 +02:00
curEndMS + = OPT_GET ( " Audio/Lead/OUT " ) - > GetInt ( ) ;
2006-01-16 22:02:54 +01:00
}
// Set changes
2009-05-07 19:52:29 +02:00
UpdateTimeEditCtrls ( ) ;
2006-01-16 22:02:54 +01:00
NeedCommit = true ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Auto/Commit " ) - > GetBool ( ) ) CommitChanges ( ) ;
2006-01-16 22:02:54 +01:00
Update ( ) ;
}
///////////////
// Event table
BEGIN_EVENT_TABLE ( AudioDisplay , wxWindow )
EVT_MOUSE_EVENTS ( AudioDisplay : : OnMouseEvent )
EVT_PAINT ( AudioDisplay : : OnPaint )
EVT_SIZE ( AudioDisplay : : OnSize )
EVT_TIMER ( Audio_Update_Timer , AudioDisplay : : OnUpdateTimer )
EVT_KEY_DOWN ( AudioDisplay : : OnKeyDown )
EVT_SET_FOCUS ( AudioDisplay : : OnGetFocus )
EVT_KILL_FOCUS ( AudioDisplay : : OnLoseFocus )
END_EVENT_TABLE ( )
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Paint
/// @param event
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnPaint ( wxPaintEvent & event ) {
if ( w = = 0 | | h = = 0 ) return ;
2008-11-14 02:21:17 +01:00
DoUpdateImage ( ) ;
2006-01-16 22:02:54 +01:00
wxPaintDC dc ( this ) ;
2009-09-05 06:06:38 +02:00
if ( origImage ) dc . DrawBitmap ( * origImage , 0 , 0 ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Mouse event
/// @param event
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnMouseEvent ( wxMouseEvent & event ) {
// Get x,y
2007-08-31 16:11:35 +02:00
int64_t x = event . GetX ( ) ;
int64_t y = event . GetY ( ) ;
2006-01-16 22:02:54 +01:00
bool karMode = karaoke - > enabled ;
bool shiftDown = event . m_shiftDown ;
2010-05-21 03:13:36 +02:00
int timelineHeight = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2006-01-16 22:02:54 +01:00
2006-02-24 02:16:27 +01:00
// Leaving event
if ( event . Leaving ( ) ) {
event . Skip ( ) ;
return ;
}
2009-06-17 01:44:06 +02:00
if ( ! player | | ! provider ) {
event . Skip ( ) ;
return ;
}
2006-01-16 22:02:54 +01:00
// Is inside?
bool inside = false ;
2006-03-07 01:12:50 +01:00
bool onScale = false ;
if ( x > = 0 & & y > = 0 & & x < w ) {
if ( y < h ) {
inside = true ;
2006-01-16 22:02:54 +01:00
2006-03-07 01:12:50 +01:00
// Get focus
2010-05-21 03:13:36 +02:00
if ( wxWindow : : FindFocus ( ) ! = this & & OPT_GET ( " Audio/Auto/Focus " ) - > GetBool ( ) ) SetFocus ( ) ;
2006-03-07 01:12:50 +01:00
}
2007-01-06 07:14:35 +01:00
else if ( y < h + timelineHeight ) onScale = true ;
2006-01-16 22:02:54 +01:00
}
2007-04-07 05:12:55 +02:00
// Buttons
bool leftIsDown = event . ButtonIsDown ( wxMOUSE_BTN_LEFT ) ;
bool rightIsDown = event . ButtonIsDown ( wxMOUSE_BTN_RIGHT ) ;
bool buttonIsDown = leftIsDown | | rightIsDown ;
bool leftClick = event . ButtonDown ( wxMOUSE_BTN_LEFT ) ;
bool rightClick = event . ButtonDown ( wxMOUSE_BTN_RIGHT ) ;
bool middleClick = event . Button ( wxMOUSE_BTN_MIDDLE ) ;
bool buttonClick = leftClick | | rightClick ;
bool defCursor = true ;
2006-02-21 22:33:15 +01:00
// Click type
2007-04-07 05:12:55 +02:00
if ( buttonClick & & ! holding ) {
2006-02-21 22:33:15 +01:00
holding = true ;
CaptureMouse ( ) ;
}
2007-04-07 05:12:55 +02:00
if ( ! buttonIsDown & & holding ) {
2006-02-21 22:33:15 +01:00
holding = false ;
2006-07-04 08:13:54 +02:00
if ( HasCapture ( ) ) ReleaseMouse ( ) ;
}
2006-01-16 22:02:54 +01:00
// Mouse wheel
if ( event . GetWheelRotation ( ) ! = 0 ) {
// Zoom or scroll?
bool zoom = shiftDown ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Wheel Default to Zoom " ) - > GetBool ( ) ) zoom = ! zoom ;
2006-01-16 22:02:54 +01:00
// Zoom
if ( zoom ) {
2007-09-21 23:00:41 +02:00
# ifdef __APPLE__
// Reverse scroll directions on Apple... ugly hack
// Otherwise left=right and right=left on systems that support four-way scrolling.
2006-01-16 22:02:54 +01:00
int step = - event . GetWheelRotation ( ) / event . GetWheelDelta ( ) ;
2007-09-21 23:00:41 +02:00
# else
int step = event . GetWheelRotation ( ) / event . GetWheelDelta ( ) ;
# endif
2006-01-16 22:02:54 +01:00
int value = box - > HorizontalZoom - > GetValue ( ) + step ;
box - > HorizontalZoom - > SetValue ( value ) ;
SetSamplesPercent ( value , true , float ( x ) / float ( w ) ) ;
}
// Scroll
else {
2007-09-21 23:00:41 +02:00
int step = - event . GetWheelRotation ( ) * w / 360 ;
2006-01-16 22:02:54 +01:00
UpdatePosition ( Position + step , false ) ;
UpdateImage ( ) ;
}
}
// Cursor drawing
2009-06-17 01:44:06 +02:00
if ( player & & ! player - > IsPlaying ( ) & & origImage ) {
2006-01-16 22:02:54 +01:00
// Draw bg
wxClientDC dc ( this ) ;
2009-09-05 06:06:38 +02:00
if ( origImage ) dc . DrawBitmap ( * origImage , 0 , 0 ) ;
2006-01-16 22:02:54 +01:00
if ( inside ) {
// Draw cursor
dc . SetLogicalFunction ( wxINVERT ) ;
dc . DrawLine ( x , 0 , x , h ) ;
2007-01-06 07:14:35 +01:00
// Time
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Display/Draw/Cursor " ) - > GetBool ( ) ) {
2007-01-06 07:14:35 +01:00
// Time string
AssTime time ;
time . SetMS ( GetMSAtX ( x ) ) ;
wxString text = time . GetASSFormated ( ) ;
// Calculate metrics
2009-06-06 04:32:31 +02:00
// FIXME: Hardcoded font name
2007-01-06 07:14:35 +01:00
wxFont font ( 10 , wxFONTFAMILY_DEFAULT , wxFONTSTYLE_NORMAL , wxFONTWEIGHT_BOLD , false , _T ( " Verdana " ) ) ;
dc . SetFont ( font ) ;
int tw , th ;
GetTextExtent ( text , & tw , & th , NULL , NULL , & font ) ;
// Set inversion
bool left = true ;
if ( x > w / 2 ) left = false ;
// Text coordinates
int dx ;
dx = x - tw / 2 ;
if ( dx < 4 ) dx = 4 ;
int max = w - tw - 4 ;
if ( dx > max ) dx = max ;
int dy = 4 ;
2008-06-21 20:34:57 +02:00
if ( karMode ) dy + = th ;
2007-01-06 07:14:35 +01:00
// Draw text
dc . SetTextForeground ( wxColour ( 64 , 64 , 64 ) ) ;
dc . DrawText ( text , dx + 1 , dy - 1 ) ;
dc . DrawText ( text , dx + 1 , dy + 1 ) ;
dc . DrawText ( text , dx - 1 , dy - 1 ) ;
dc . DrawText ( text , dx - 1 , dy + 1 ) ;
dc . SetTextForeground ( wxColour ( 255 , 255 , 255 ) ) ;
dc . DrawText ( text , dx , dy ) ;
}
2006-01-16 22:02:54 +01:00
}
}
2006-03-07 01:12:50 +01:00
// Scale dragging
2006-07-02 00:49:09 +02:00
if ( ( hold = = 0 & & onScale ) | | draggingScale ) {
2006-03-07 01:12:50 +01:00
if ( event . ButtonDown ( wxMOUSE_BTN_LEFT ) ) {
lastDragX = x ;
draggingScale = true ;
}
else if ( holding ) {
int delta = lastDragX - x ;
lastDragX = x ;
UpdatePosition ( Position + delta ) ;
UpdateImage ( ) ;
Refresh ( false ) ;
2006-07-02 00:49:09 +02:00
SetCursor ( wxNullCursor ) ;
return ;
2006-03-07 01:12:50 +01:00
}
else draggingScale = false ;
}
// Outside
2006-07-02 00:49:09 +02:00
if ( ! inside & & hold = = 0 ) return ;
2006-03-06 01:45:24 +01:00
2007-04-07 05:12:55 +02:00
// Left click
if ( leftClick ) {
2006-03-05 05:41:59 +01:00
SetFocus ( ) ;
2006-01-16 22:02:54 +01:00
}
// Right click
2007-04-07 05:12:55 +02:00
if ( rightClick ) {
2006-02-21 22:33:15 +01:00
SetFocus ( ) ;
2006-01-16 22:02:54 +01:00
if ( karaoke - > enabled ) {
int syl = GetSyllableAtX ( x ) ;
if ( syl ! = - 1 ) {
2007-06-23 02:21:20 +02:00
int start = karaoke - > syllables . at ( syl ) . start_time * 10 + dialogue - > Start . GetMS ( ) ;
int count = karaoke - > syllables . at ( syl ) . duration * 10 ;
2009-06-25 02:32:33 +02:00
Play ( start , start + count ) ;
2006-01-16 22:02:54 +01:00
}
}
}
2007-04-07 05:12:55 +02:00
// Middle click
if ( middleClick ) {
SetFocus ( ) ;
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
VideoContext : : Get ( ) - > JumpToTime ( GetMSAtX ( x ) , true ) ;
}
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Timing
if ( hasSel ) {
bool updated = false ;
// Grab start/end
if ( hold = = 0 ) {
bool gotGrab = false ;
2007-09-22 00:36:02 +02:00
bool karTime = karMode & & !
# ifdef __APPLE__
event . CmdDown ( ) ;
# else
event . ControlDown ( ) ;
# endif
2007-01-06 00:43:24 +01:00
2007-01-15 04:50:49 +01:00
// Line timing mode
2007-01-06 21:11:38 +01:00
if ( ! karTime ) {
2007-01-15 04:50:49 +01:00
// Grab start
2010-05-21 03:13:36 +02:00
if ( abs64 ( x - selStart ) < 6 & & OPT_GET ( " Audio/Display/Dragging Times " ) - > GetBool ( ) = = false ) {
2007-01-06 00:43:24 +01:00
wxCursor cursor ( wxCURSOR_SIZEWE ) ;
SetCursor ( cursor ) ;
defCursor = false ;
2007-01-15 04:50:49 +01:00
if ( buttonClick ) {
2007-01-06 00:43:24 +01:00
hold = 1 ;
gotGrab = true ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Grab end
2010-05-21 03:13:36 +02:00
else if ( abs64 ( x - selEnd ) < 6 & & OPT_GET ( " Audio/Display/Dragging Times " ) - > GetBool ( ) = = false ) {
2007-01-06 00:43:24 +01:00
wxCursor cursor ( wxCURSOR_SIZEWE ) ;
SetCursor ( cursor ) ;
defCursor = false ;
2007-01-15 04:50:49 +01:00
if ( buttonClick ) {
2007-01-06 00:43:24 +01:00
hold = 2 ;
gotGrab = true ;
2006-01-16 22:02:54 +01:00
}
}
2007-01-15 04:50:49 +01:00
// Dragging nothing, time from scratch
else {
if ( buttonClick ) {
if ( leftClick ) hold = 3 ;
else hold = 2 ;
lastX = x ;
gotGrab = true ;
}
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-15 04:50:49 +01:00
// Karaoke mode
2007-01-06 21:11:38 +01:00
else {
2007-01-15 04:50:49 +01:00
// Look for a syllable
2007-08-31 16:11:35 +02:00
int64_t pos , len , curpos ;
2007-06-23 02:21:20 +02:00
AudioKaraokeSyllable * curSyl ;
2007-01-06 00:43:24 +01:00
size_t karn = karaoke - > syllables . size ( ) ;
for ( size_t i = 0 ; i < karn ; i + + ) {
curSyl = & karaoke - > syllables . at ( i ) ;
2007-06-23 02:21:20 +02:00
len = curSyl - > duration * 10 ;
curpos = curSyl - > start_time * 10 ;
2007-01-06 00:43:24 +01:00
if ( len ! = - 1 ) {
pos = GetXAtMS ( curStartMS + len + curpos ) ;
2007-01-15 04:50:49 +01:00
// Grabbing syllable boundary
2009-05-22 16:30:51 +02:00
if ( abs64 ( x - pos ) < 7 ) {
2007-01-06 00:43:24 +01:00
wxCursor cursor ( wxCURSOR_SIZEWE ) ;
SetCursor ( cursor ) ;
defCursor = false ;
if ( event . LeftIsDown ( ) ) {
hold = 4 ;
holdSyl = ( int ) i ;
gotGrab = true ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 00:43:24 +01:00
break ;
2006-01-16 22:02:54 +01:00
}
}
}
2007-01-15 04:50:49 +01:00
// No syllable found, select if possible
if ( hold = = 0 & & leftClick ) {
int syl = GetSyllableAtX ( x ) ;
if ( syl ! = - 1 ) {
karaoke - > SetSyllable ( syl ) ;
updated = true ;
}
2006-01-16 22:02:54 +01:00
}
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Drag start/end
if ( hold ! = 0 ) {
// Dragging
if ( buttonIsDown ) {
2007-01-06 04:40:58 +01:00
// Drag from nothing or straight timing
2007-01-06 00:43:24 +01:00
if ( hold = = 3 & & buttonIsDown ) {
if ( ! karMode ) {
if ( leftIsDown ) curStartMS = GetMSAtX ( x ) ;
else curEndMS = GetMSAtX ( x ) ;
updated = true ;
2007-01-06 04:40:58 +01:00
diagUpdated = true ;
2007-01-06 00:43:24 +01:00
2010-05-21 03:13:36 +02:00
if ( leftIsDown & & abs ( ( long ) ( x - lastX ) ) > OPT_GET ( " Audio/Start Drag Sensitivity " ) - > GetInt ( ) ) {
2007-01-06 05:19:00 +01:00
selStart = lastX ;
2007-01-06 00:43:24 +01:00
selEnd = x ;
2007-04-07 04:39:18 +02:00
curStartMS = GetBoundarySnap ( GetMSAtX ( lastX ) , 10 , event . ShiftDown ( ) , true ) ;
2007-01-06 00:43:24 +01:00
curEndMS = GetMSAtX ( x ) ;
hold = 2 ;
2006-01-16 22:02:54 +01:00
}
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Drag start
if ( hold = = 1 & & buttonIsDown ) {
// Set new value
if ( x ! = selStart ) {
2007-04-07 04:39:18 +02:00
int snapped = GetBoundarySnap ( GetMSAtX ( x ) , 10 , event . ShiftDown ( ) , true ) ;
2007-01-06 23:07:48 +01:00
selStart = GetXAtMS ( snapped ) ;
2007-01-06 00:43:24 +01:00
if ( selStart > selEnd ) {
int temp = selStart ;
selStart = selEnd ;
selEnd = temp ;
hold = 2 ;
2007-01-06 23:13:56 +01:00
curEndMS = snapped ;
snapped = GetMSAtX ( selStart ) ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 23:13:56 +01:00
curStartMS = snapped ;
2007-01-06 00:43:24 +01:00
updated = true ;
diagUpdated = true ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Drag end
if ( hold = = 2 & & buttonIsDown ) {
// Set new value
if ( x ! = selEnd ) {
2007-04-07 04:39:18 +02:00
int snapped = GetBoundarySnap ( GetMSAtX ( x ) , 10 , event . ShiftDown ( ) , false ) ;
2007-01-06 23:07:48 +01:00
selEnd = GetXAtMS ( snapped ) ;
//selEnd = GetBoundarySnap(x,event.ShiftDown()?0:10,false);
2007-01-06 00:43:24 +01:00
if ( selStart > selEnd ) {
int temp = selStart ;
selStart = selEnd ;
selEnd = temp ;
hold = 1 ;
2007-01-06 23:13:56 +01:00
curStartMS = snapped ;
snapped = GetMSAtX ( selEnd ) ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 23:13:56 +01:00
curEndMS = snapped ;
2007-01-06 00:43:24 +01:00
updated = true ;
diagUpdated = true ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Drag karaoke
if ( hold = = 4 & & leftIsDown ) {
// Set new value
int curpos , len , pos , nkar ;
2007-06-23 02:21:20 +02:00
AudioKaraokeSyllable * curSyl = NULL , * nextSyl = NULL ;
2007-01-06 00:43:24 +01:00
curSyl = & karaoke - > syllables . at ( holdSyl ) ;
nkar = ( int ) karaoke - > syllables . size ( ) ;
if ( holdSyl < nkar - 1 ) {
nextSyl = & karaoke - > syllables . at ( holdSyl + 1 ) ;
}
2007-06-23 02:21:20 +02:00
curpos = curSyl - > start_time ;
len = curSyl - > duration ;
2007-01-06 00:43:24 +01:00
pos = GetXAtMS ( curStartMS + ( len + curpos ) * 10 ) ;
if ( x ! = pos ) {
// Calculate delta in centiseconds
2007-08-31 16:11:35 +02:00
int delta = ( ( int64_t ) ( x - pos ) * samples * 100 ) / provider - > GetSampleRate ( ) ;
2007-01-06 00:43:24 +01:00
// Apply delta
int deltaMode = 0 ;
if ( shiftDown ) deltaMode = 1 ;
// else if (ctrlDown) deltaMode = 2;
bool result = karaoke - > SyllableDelta ( holdSyl , delta , deltaMode ) ;
if ( result ) {
updated = true ;
diagUpdated = true ;
}
2006-01-16 22:02:54 +01:00
}
}
2007-01-06 00:43:24 +01:00
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Release
else {
// Commit changes
if ( diagUpdated ) {
diagUpdated = false ;
NeedCommit = true ;
2007-01-08 04:05:26 +01:00
if ( curStartMS < = curEndMS ) {
2007-07-27 10:24:49 +02:00
UpdateTimeEditCtrls ( ) ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Auto/Commit " ) - > GetBool ( ) ) CommitChanges ( ) ;
2007-01-08 04:05:26 +01:00
}
2007-01-06 00:43:24 +01:00
else UpdateImage ( true ) ;
}
2006-01-16 22:02:54 +01:00
2007-01-06 00:43:24 +01:00
// Update stuff
SetCursor ( wxNullCursor ) ;
hold = 0 ;
2006-01-16 22:02:54 +01:00
}
}
2007-01-06 00:43:24 +01:00
// Update stuff
if ( updated ) {
2007-01-08 04:05:26 +01:00
if ( diagUpdated ) NeedCommit = true ;
2009-05-15 17:23:34 +02:00
if ( karaoke - > enabled & & ! playingToEnd ) {
2007-07-06 03:36:01 +02:00
AudioKaraokeSyllable & syl = karaoke - > syllables [ karaoke - > curSyllable ] ;
player - > SetEndPosition ( GetSampleAtMS ( curStartMS + ( syl . start_time + syl . duration ) * 10 ) ) ;
2009-05-15 17:23:34 +02:00
} else if ( ! playingToEnd ) {
2007-07-06 03:36:01 +02:00
player - > SetEndPosition ( GetSampleAtX ( selEnd ) ) ;
}
2007-01-15 04:50:49 +01:00
if ( hold ! = 0 ) {
wxCursor cursor ( wxCURSOR_SIZEWE ) ;
SetCursor ( cursor ) ;
}
2007-01-06 00:43:24 +01:00
UpdateImage ( true ) ;
2006-01-16 22:02:54 +01:00
}
}
2007-01-06 00:43:24 +01:00
// Not holding
else {
hold = 0 ;
}
2006-01-16 22:02:54 +01:00
// Restore cursor
if ( defCursor ) SetCursor ( wxNullCursor ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Get snap to boundary
/// @param ms
/// @param rangeX
/// @param shiftHeld
/// @param start
/// @return
2007-04-07 04:39:18 +02:00
int AudioDisplay : : GetBoundarySnap ( int ms , int rangeX , bool shiftHeld , bool start ) {
2007-01-06 21:11:38 +01:00
// Range?
2007-01-06 23:07:48 +01:00
if ( rangeX < = 0 ) return ms ;
// Convert range into miliseconds
int rangeMS = rangeX * samples * 1000 / provider - > GetSampleRate ( ) ;
2007-01-06 21:11:38 +01:00
2007-04-07 04:39:18 +02:00
// Keyframe boundaries
2007-01-06 05:19:00 +01:00
wxArrayInt boundaries ;
2010-05-21 03:13:36 +02:00
bool snapKey = OPT_GET ( " Audio/Display/Snap/Keyframes " ) - > GetBool ( ) ;
2007-04-07 04:39:18 +02:00
if ( shiftHeld ) snapKey = ! snapKey ;
2010-05-21 03:13:36 +02:00
if ( snapKey & & VideoContext : : Get ( ) - > KeyFramesLoaded ( ) & & OPT_GET ( " Audio/Display/Draw/Keyframes " ) - > GetBool ( ) ) {
2007-08-31 16:11:35 +02:00
int64_t keyMS ;
2007-01-21 07:30:19 +01:00
wxArrayInt keyFrames = VideoContext : : Get ( ) - > GetKeyFrames ( ) ;
2007-01-06 23:07:48 +01:00
int frame ;
2007-01-06 05:19:00 +01:00
for ( unsigned int i = 0 ; i < keyFrames . Count ( ) ; i + + ) {
2007-01-06 23:07:48 +01:00
frame = keyFrames [ i ] ;
if ( ! start ) frame - - ;
if ( frame < 0 ) frame = 0 ;
keyMS = VFR_Output . GetTimeAtFrame ( frame , start ) ;
//if (start) keyX++;
if ( GetXAtMS ( keyMS ) > = 0 & & GetXAtMS ( keyMS ) < w ) boundaries . Add ( keyMS ) ;
2007-01-06 05:19:00 +01:00
}
}
// Other subtitles' boundaries
2010-05-21 03:13:36 +02:00
int inactiveType = OPT_GET ( " Audio/Inactive Lines Display Mode " ) - > GetInt ( ) ;
bool snapLines = OPT_GET ( " Audio/Display/Snap/Other Lines " ) - > GetBool ( ) ;
2007-04-07 04:39:18 +02:00
if ( shiftHeld ) snapLines = ! snapLines ;
if ( snapLines & & ( inactiveType = = 1 | | inactiveType = = 2 ) ) {
2007-01-06 05:19:00 +01:00
AssDialogue * shade ;
int shadeX1 , shadeX2 ;
int shadeFrom , shadeTo ;
// Get range
if ( inactiveType = = 1 ) {
shadeFrom = this - > line_n - 1 ;
shadeTo = shadeFrom + 1 ;
}
else {
shadeFrom = 0 ;
shadeTo = grid - > GetRows ( ) ;
}
for ( int j = shadeFrom ; j < shadeTo ; j + + ) {
if ( j = = line_n ) continue ;
shade = grid - > GetDialogue ( j ) ;
if ( shade ) {
// Get coordinates
shadeX1 = GetXAtMS ( shade - > Start . GetMS ( ) ) ;
shadeX2 = GetXAtMS ( shade - > End . GetMS ( ) ) ;
2007-01-06 23:07:48 +01:00
if ( shadeX1 > = 0 & & shadeX1 < w ) boundaries . Add ( shade - > Start . GetMS ( ) ) ;
if ( shadeX2 > = 0 & & shadeX2 < w ) boundaries . Add ( shade - > End . GetMS ( ) ) ;
2007-01-06 05:19:00 +01:00
}
}
}
2007-01-06 23:07:48 +01:00
// See if ms falls within range of any of them
int minDist = rangeMS + 1 ;
int bestMS = ms ;
2007-01-06 05:19:00 +01:00
for ( unsigned int i = 0 ; i < boundaries . Count ( ) ; i + + ) {
2007-01-06 23:07:48 +01:00
if ( abs ( ms - boundaries [ i ] ) < minDist ) {
bestMS = boundaries [ i ] ;
minDist = abs ( ms - boundaries [ i ] ) ;
2007-01-06 05:19:00 +01:00
}
}
// Return best match
2007-01-06 23:07:48 +01:00
return bestMS ;
2007-01-06 05:19:00 +01:00
}
//
// SCRUBBING CODE, REMOVED FROM THE FUNCTION ABOVE
/*
// Stop scrubbing
bool scrubButton = false & & event . ButtonIsDown ( wxMOUSE_BTN_MIDDLE ) ;
if ( scrubbing & & ! scrubButton ) {
// Release mouse
scrubbing = false ;
if ( HasCapture ( ) ) ReleaseMouse ( ) ;
// Stop player
player - > Stop ( ) ;
player - > SetProvider ( provider ) ;
delete scrubProvider ;
}
// Start scrubbing
if ( ! scrubbing & & scrubButton & & provider - > GetChannels ( ) = = 1 ) {
// Get mouse
CaptureMouse ( ) ;
scrubbing = true ;
// Initialize provider
player - > Stop ( ) ;
scrubProvider = new StreamAudioProvider ( ) ;
scrubProvider - > SetParams ( provider - > GetChannels ( ) , provider - > GetSampleRate ( ) , provider - > GetBytesPerSample ( ) ) ;
player - > SetProvider ( scrubProvider ) ;
// Set variables
scrubLastPos = GetSampleAtX ( x ) ;
scrubTime = clock ( ) ;
scrubLastRate = provider - > GetSampleRate ( ) ;
}
// Scrub
if ( scrubbing & & scrubButton ) {
// Get current data
2007-08-31 16:11:35 +02:00
int64_t exactPos = MAX ( 0 , GetSampleAtX ( x ) ) ;
2007-01-06 05:19:00 +01:00
int curScrubTime = clock ( ) ;
int scrubDeltaTime = curScrubTime - scrubTime ;
bool invert = exactPos < scrubLastPos ;
2007-08-31 16:11:35 +02:00
int64_t curScrubPos = exactPos ;
2007-01-06 05:19:00 +01:00
if ( scrubDeltaTime > 0 ) {
// Get derived data
int rateChange = provider - > GetSampleRate ( ) / 20 ;
int curRate = MID ( int ( scrubLastRate - rateChange ) , abs ( int ( exactPos - scrubLastPos ) ) * CLOCKS_PER_SEC / scrubDeltaTime , int ( scrubLastRate + rateChange ) ) ;
if ( abs ( curRate - scrubLastRate ) < rateChange ) curRate = scrubLastRate ;
curScrubPos = scrubLastPos + ( curRate * scrubDeltaTime / CLOCKS_PER_SEC * ( invert ? - 1 : 1 ) ) ;
2007-08-31 16:11:35 +02:00
int64_t scrubDelta = curScrubPos - scrubLastPos ;
2007-01-06 05:19:00 +01:00
scrubLastRate = curRate ;
// Copy data to buffer
if ( scrubDelta ! = 0 ) {
// Create buffer
int bufSize = scrubDeltaTime * scrubProvider - > GetSampleRate ( ) / CLOCKS_PER_SEC ;
short * buf = new short [ bufSize ] ;
// Flag as inverted, if necessary
if ( invert ) scrubDelta = - scrubDelta ;
// Copy data from original provider to temp buffer
short * temp = new short [ scrubDelta ] ;
provider - > GetAudio ( temp , MIN ( curScrubPos , scrubLastPos ) , scrubDelta ) ;
// Scale
float scale = float ( double ( scrubDelta ) / double ( bufSize ) ) ;
float start , end ;
int istart , iend ;
float tempfinal ;
for ( int i = 0 ; i < bufSize ; i + + ) {
start = i * scale ;
end = ( i + 1 ) * scale ;
istart = ( int ) start ;
iend = MIN ( ( int ) end , scrubDelta - 1 ) ;
if ( istart = = iend ) tempfinal = temp [ istart ] * ( end - start ) ;
else {
tempfinal = temp [ istart ] * ( 1 + istart - start ) + temp [ iend ] * ( end - iend ) ;
for ( int j = istart + 1 ; j < iend ; j + + ) tempfinal + = temp [ i ] ;
}
buf [ i ] = tempfinal / scale ;
}
//int len = MIN(bufSize,scrubDelta);
//for (int i=0;i<len;i++) buf[i] = temp[i];
//for (int i=len;i<bufSize;i++) buf[i] = 0;
delete temp ;
// Invert
if ( invert ) {
short aux ;
for ( int i = 0 ; i < bufSize / 2 ; i + + ) {
aux = buf [ i ] ;
buf [ i ] = buf [ bufSize - i - 1 ] ;
buf [ bufSize - i - 1 ] = aux ;
}
}
// Send data to provider
scrubProvider - > Append ( buf , bufSize ) ;
if ( ! player - > IsPlaying ( ) ) player - > Play ( 0 , ~ 0ULL ) ;
delete buf ;
}
}
// Update last pos and time
scrubLastPos = curScrubPos ;
scrubTime = curScrubTime ;
// Return
return ;
}
*/
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Size event
/// @param event
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnSize ( wxSizeEvent & event ) {
// Set size
GetClientSize ( & w , & h ) ;
2010-05-21 03:13:36 +02:00
h - = OPT_GET ( " Audio/Display/Draw/Timeline " ) - > GetBool ( ) ? 20 : 0 ;
2006-01-16 22:02:54 +01:00
// Update image
2008-01-25 21:53:12 +01:00
UpdateSamples ( ) ;
2008-01-20 21:09:49 +01:00
if ( samples ) {
UpdatePosition ( PositionSample / samples ) ;
}
2006-01-16 22:02:54 +01:00
UpdateImage ( ) ;
// Update scrollbar
UpdateScrollbar ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Timer event
/// @param event
/// @return
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnUpdateTimer ( wxTimerEvent & event ) {
2007-06-23 04:43:42 +02:00
if ( ! origImage )
return ;
2006-01-16 22:02:54 +01:00
// Get lock and check if it's OK
2006-02-25 08:41:18 +01:00
if ( player - > GetMutex ( ) ) {
wxMutexLocker locker ( * player - > GetMutex ( ) ) ;
2006-02-25 07:04:46 +01:00
if ( ! locker . IsOk ( ) ) return ;
}
2006-02-25 08:41:18 +01:00
if ( ! player - > IsPlaying ( ) ) return ;
2006-01-16 22:02:54 +01:00
// Get DCs
//wxMutexGuiEnter();
wxClientDC dc ( this ) ;
// Draw cursor
int curpos = - 1 ;
2006-02-25 08:41:18 +01:00
if ( player - > IsPlaying ( ) ) {
2007-08-31 16:11:35 +02:00
int64_t curPos = player - > GetCurrentPosition ( ) ;
2006-03-06 00:01:02 +01:00
if ( curPos > player - > GetStartPosition ( ) & & curPos < player - > GetEndPosition ( ) ) {
// Scroll if needed
int posX = GetXAtSample ( curPos ) ;
2006-03-06 00:41:00 +01:00
bool fullDraw = false ;
2006-03-20 22:48:01 +01:00
bool centerLock = false ;
2010-05-21 03:13:36 +02:00
bool scrollToCursor = OPT_GET ( " Audio/Lock Scroll on Cursor " ) - > GetBool ( ) ;
2006-03-06 00:41:00 +01:00
if ( centerLock ) {
int goTo = MAX ( 0 , curPos - w * samples / 2 ) ;
if ( goTo > = 0 ) {
UpdatePosition ( goTo , true ) ;
UpdateImage ( ) ;
fullDraw = true ;
}
}
else {
2006-03-20 22:48:01 +01:00
if ( scrollToCursor ) {
if ( posX < 80 | | posX > w - 80 ) {
int goTo = MAX ( 0 , curPos - 80 * samples ) ;
if ( goTo > = 0 ) {
UpdatePosition ( goTo , true ) ;
UpdateImage ( ) ;
fullDraw = true ;
}
2006-03-06 00:41:00 +01:00
}
}
2006-03-06 00:01:02 +01:00
}
// Draw cursor
wxMemoryDC src ;
curpos = GetXAtSample ( curPos ) ;
2007-09-21 23:24:32 +02:00
if ( curpos > = 0 & & curpos < GetClientSize ( ) . GetWidth ( ) ) {
2010-05-21 03:13:36 +02:00
dc . SetPen ( wxPen ( lagi_wxColour ( OPT_GET ( " Colour/Audio Display/Play Cursor " ) - > GetColour ( ) ) ) ) ;
2007-09-21 23:24:32 +02:00
src . SelectObject ( * origImage ) ;
if ( fullDraw ) {
//dc.Blit(0,0,w,h,&src,0,0);
dc . DrawLine ( curpos , 0 , curpos , h ) ;
//dc.Blit(0,0,curpos-10,h,&src,0,0);
//dc.Blit(curpos+10,0,w-curpos-10,h,&src,curpos+10,0);
}
else {
dc . Blit ( oldCurPos , 0 , 1 , h , & src , oldCurPos , 0 ) ;
dc . DrawLine ( curpos , 0 , curpos , h ) ;
}
2006-03-06 00:41:00 +01:00
}
2006-01-16 22:02:54 +01:00
}
2006-03-06 00:01:02 +01:00
else {
if ( curPos > player - > GetEndPosition ( ) + 8192 ) {
player - > Stop ( ) ;
}
wxMemoryDC src ;
src . SelectObject ( * origImage ) ;
dc . Blit ( oldCurPos , 0 , 1 , h , & src , oldCurPos , 0 ) ;
2006-01-16 22:02:54 +01:00
}
}
2006-03-06 00:01:02 +01:00
// Restore background
else {
wxMemoryDC src ;
src . SelectObject ( * origImage ) ;
dc . Blit ( oldCurPos , 0 , 1 , h , & src , oldCurPos , 0 ) ;
}
2006-01-16 22:02:54 +01:00
oldCurPos = curpos ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Key down
/// @param event
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnKeyDown ( wxKeyEvent & event ) {
int key = event . GetKeyCode ( ) ;
2007-09-22 17:16:48 +02:00
# ifdef __APPLE__
Hotkeys . SetPressed ( key , event . m_metaDown , event . m_altDown , event . m_shiftDown ) ;
# else
2006-01-16 22:02:54 +01:00
Hotkeys . SetPressed ( key , event . m_controlDown , event . m_altDown , event . m_shiftDown ) ;
2007-09-22 17:16:48 +02:00
# endif
2006-01-16 22:02:54 +01:00
// Accept
if ( Hotkeys . IsPressed ( _T ( " Audio Commit " ) ) ) {
2007-01-06 04:40:58 +01:00
CommitChanges ( true ) ;
//ChangeLine(1);
2006-01-16 22:02:54 +01:00
}
// Accept (SSA's "Grab times")
if ( Hotkeys . IsPressed ( _T ( " Audio Commit Alt " ) ) ) {
2007-01-06 04:40:58 +01:00
CommitChanges ( true ) ;
2006-01-16 22:02:54 +01:00
}
// Accept (stay)
if ( Hotkeys . IsPressed ( _T ( " Audio Commit (Stay) " ) ) ) {
CommitChanges ( ) ;
}
// Previous
if ( Hotkeys . IsPressed ( _T ( " Audio Prev Line " ) ) | | Hotkeys . IsPressed ( _T ( " Audio Prev Line Alt " ) ) ) {
Prev ( ) ;
}
// Next
if ( Hotkeys . IsPressed ( _T ( " Audio Next Line " ) ) | | Hotkeys . IsPressed ( _T ( " Audio Next Line Alt " ) ) ) {
Next ( ) ;
}
// Play
if ( Hotkeys . IsPressed ( _T ( " Audio Play " ) ) | | Hotkeys . IsPressed ( _T ( " Audio Play Alt " ) ) ) {
2007-01-06 00:43:24 +01:00
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
Play ( start , end ) ;
2006-01-16 22:02:54 +01:00
}
2007-01-06 05:27:09 +01:00
// Play/Stop
if ( Hotkeys . IsPressed ( _T ( " Audio Play or Stop " ) ) ) {
if ( player - > IsPlaying ( ) ) Stop ( ) ;
else {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
Play ( start , end ) ;
}
}
// Stop
if ( Hotkeys . IsPressed ( _T ( " Audio Stop " ) ) ) {
Stop ( ) ;
}
2006-01-16 22:02:54 +01:00
// Increase length
if ( Hotkeys . IsPressed ( _T ( " Audio Karaoke Increase Len " ) ) ) {
if ( karaoke - > enabled ) {
bool result = karaoke - > SyllableDelta ( karaoke - > curSyllable , 1 , 0 ) ;
if ( result ) diagUpdated = true ;
}
}
// Increase length (shift)
if ( Hotkeys . IsPressed ( _T ( " Audio Karaoke Increase Len Shift " ) ) ) {
if ( karaoke - > enabled ) {
bool result = karaoke - > SyllableDelta ( karaoke - > curSyllable , 1 , 1 ) ;
if ( result ) diagUpdated = true ;
}
}
// Decrease length
if ( Hotkeys . IsPressed ( _T ( " Audio Karaoke Decrease Len " ) ) ) {
if ( karaoke - > enabled ) {
bool result = karaoke - > SyllableDelta ( karaoke - > curSyllable , - 1 , 0 ) ;
if ( result ) diagUpdated = true ;
}
}
// Decrease length (shift)
if ( Hotkeys . IsPressed ( _T ( " Audio Karaoke Decrease Len Shift " ) ) ) {
if ( karaoke - > enabled ) {
bool result = karaoke - > SyllableDelta ( karaoke - > curSyllable , - 1 , 1 ) ;
if ( result ) diagUpdated = true ;
}
}
// Move backwards
if ( Hotkeys . IsPressed ( _T ( " Audio Scroll Left " ) ) ) {
UpdatePosition ( Position - 128 , false ) ;
UpdateImage ( ) ;
}
// Move forward
if ( Hotkeys . IsPressed ( _T ( " Audio Scroll Right " ) ) ) {
UpdatePosition ( Position + 128 , false ) ;
UpdateImage ( ) ;
}
// Play first 500 ms
if ( Hotkeys . IsPressed ( _T ( " Audio Play First 500ms " ) ) ) {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
int e = start + 500 ;
if ( e > end ) e = end ;
Play ( start , e ) ;
}
// Play last 500 ms
if ( Hotkeys . IsPressed ( _T ( " Audio Play Last 500ms " ) ) ) {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
int s = end - 500 ;
if ( s < start ) s = start ;
Play ( s , end ) ;
}
// Play 500 ms before
if ( Hotkeys . IsPressed ( _T ( " Audio Play 500ms Before " ) ) ) {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
Play ( start - 500 , start ) ;
}
// Play 500 ms after
if ( Hotkeys . IsPressed ( _T ( " Audio Play 500ms After " ) ) ) {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
Play ( end , end + 500 ) ;
}
2006-07-01 08:37:46 +02:00
// Play to end of file
if ( Hotkeys . IsPressed ( _T ( " Audio Play To End " ) ) ) {
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
Play ( start , - 1 ) ;
}
2006-01-16 22:02:54 +01:00
// Play original line
if ( Hotkeys . IsPressed ( _T ( " Audio Play Original Line " ) ) ) {
int start = 0 , end = 0 ;
GetTimesDialogue ( start , end ) ;
2007-01-06 00:43:24 +01:00
SetSelection ( start , end ) ;
2006-01-16 22:02:54 +01:00
Play ( start , end ) ;
}
// Lead in
if ( Hotkeys . IsPressed ( _T ( " Audio Add Lead In " ) ) ) {
AddLead ( true , false ) ;
}
// Lead out
if ( Hotkeys . IsPressed ( _T ( " Audio Add Lead Out " ) ) ) {
AddLead ( false , true ) ;
}
// Update
if ( diagUpdated ) {
diagUpdated = false ;
NeedCommit = true ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " Audio/Auto/Commit " ) - > GetBool ( ) & & curStartMS < = curEndMS ) CommitChanges ( ) ;
2007-01-06 00:43:24 +01:00
else UpdateImage ( true ) ;
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Change line
/// @param delta
/// @param block
/// @return
2009-04-26 03:02:23 +02:00
void AudioDisplay : : ChangeLine ( int delta , bool block ) {
2006-01-16 22:02:54 +01:00
if ( dialogue ) {
// Get next line number and make sure it's within bounds
2009-04-26 03:02:23 +02:00
int next ;
if ( block & & grid - > IsInSelection ( line_n ) ) next = grid - > GetLastSelRow ( ) + delta ;
else next = line_n + delta ;
2006-02-20 08:12:01 +01:00
if ( next = = - 1 ) next = 0 ;
if ( next = = grid - > GetRows ( ) ) next = grid - > GetRows ( ) - 1 ;
2006-01-16 22:02:54 +01:00
// Set stuff
NeedCommit = false ;
dialogue = NULL ;
grid - > editBox - > SetToLine ( next ) ;
grid - > SelectRow ( next ) ;
2006-12-18 21:13:23 +01:00
grid - > MakeCellVisible ( next , 0 , true ) ;
2006-02-20 08:12:01 +01:00
if ( ! dialogue ) UpdateImage ( true ) ;
else UpdateImage ( false ) ;
2006-01-16 22:02:54 +01:00
line_n = next ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Next
/// @param play
/// @return
2007-07-27 10:24:49 +02:00
void AudioDisplay : : Next ( bool play ) {
2006-01-16 22:02:54 +01:00
// Karaoke
if ( karaoke - > enabled ) {
2006-02-20 08:12:01 +01:00
int nextSyl = karaoke - > curSyllable + 1 ;
bool needsUpdate = true ;
2006-01-16 22:02:54 +01:00
// Last syllable; jump to next
2006-02-20 08:12:01 +01:00
if ( nextSyl > = ( signed int ) karaoke - > syllables . size ( ) ) {
// Already last?
if ( line_n = = grid - > GetRows ( ) - 1 ) return ;
2006-01-16 22:02:54 +01:00
if ( NeedCommit ) {
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;
if ( result = = wxYES ) {
CommitChanges ( ) ;
}
else if ( result = = wxCANCEL ) {
2006-08-28 00:29:14 +02:00
karaoke - > curSyllable = ( int ) karaoke - > syllables . size ( ) - 1 ;
2006-01-16 22:02:54 +01:00
return ;
}
}
2006-02-20 08:12:01 +01:00
nextSyl = 0 ;
2006-01-16 22:02:54 +01:00
karaoke - > curSyllable = 0 ;
ChangeLine ( 1 ) ;
2006-02-20 08:12:01 +01:00
needsUpdate = false ;
2006-01-16 22:02:54 +01:00
}
// Set syllable
2006-02-20 08:12:01 +01:00
karaoke - > SetSyllable ( nextSyl ) ;
if ( needsUpdate ) Update ( ) ;
2006-01-16 22:02:54 +01:00
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
2007-07-27 10:24:49 +02:00
if ( play ) Play ( start , end ) ;
2006-01-16 22:02:54 +01:00
}
// Plain mode
else {
ChangeLine ( 1 ) ;
}
2007-06-20 04:18:55 +02:00
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Previous
/// @param play
/// @return
2007-07-27 10:24:49 +02:00
void AudioDisplay : : Prev ( bool play ) {
2006-01-16 22:02:54 +01:00
// Karaoke
if ( karaoke - > enabled ) {
2006-02-20 08:12:01 +01:00
int nextSyl = karaoke - > curSyllable - 1 ;
bool needsUpdate = true ;
2006-01-16 22:02:54 +01:00
// First syllable; jump line
2006-02-20 08:12:01 +01:00
if ( nextSyl < 0 ) {
// Already first?
if ( line_n = = 0 ) return ;
2006-01-16 22:02:54 +01:00
if ( NeedCommit ) {
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 ) {
CommitChanges ( ) ;
}
else if ( result = = wxCANCEL ) {
2006-02-19 07:05:15 +01:00
karaoke - > curSyllable = 0 ;
2006-01-16 22:02:54 +01:00
return ;
}
}
2006-02-20 08:12:01 +01:00
karaoke - > curSyllable = - 1 ;
2006-01-16 22:02:54 +01:00
ChangeLine ( - 1 ) ;
2006-02-20 08:12:01 +01:00
needsUpdate = false ;
2006-01-16 22:02:54 +01:00
}
// Set syllable
2006-02-20 08:12:01 +01:00
karaoke - > SetSyllable ( nextSyl ) ;
if ( needsUpdate ) Update ( ) ;
2006-01-16 22:02:54 +01:00
int start = 0 , end = 0 ;
GetTimesSelection ( start , end ) ;
2007-07-27 10:24:49 +02:00
if ( play ) Play ( start , end ) ;
2006-01-16 22:02:54 +01:00
}
// Plain mode
else {
ChangeLine ( - 1 ) ;
}
2007-06-20 04:18:55 +02:00
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Gets syllable at x position
/// @param x
/// @return
2006-01-16 22:02:54 +01:00
int AudioDisplay : : GetSyllableAtX ( int x ) {
if ( ! karaoke - > enabled ) return - 1 ;
int ms = GetMSAtX ( x ) ;
size_t syllables = karaoke - > syllables . size ( ) ; ;
int sylstart , sylend ;
// Find a matching syllable
for ( size_t i = 0 ; i < syllables ; i + + ) {
2007-06-23 02:21:20 +02:00
sylstart = karaoke - > syllables . at ( i ) . start_time * 10 + curStartMS ;
sylend = karaoke - > syllables . at ( i ) . duration * 10 + sylstart ;
2006-01-16 22:02:54 +01:00
if ( ms > = sylstart & & ms < sylend ) {
2006-08-28 00:29:14 +02:00
return ( int ) i ;
2006-01-16 22:02:54 +01:00
}
}
return - 1 ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Focus events
/// @param event
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnGetFocus ( wxFocusEvent & event ) {
if ( ! hasFocus ) {
hasFocus = true ;
UpdateImage ( true ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
/// @param event
2006-01-16 22:02:54 +01:00
void AudioDisplay : : OnLoseFocus ( wxFocusEvent & event ) {
2006-03-16 00:53:44 +01:00
if ( hasFocus & & loaded ) {
2006-01-16 22:02:54 +01:00
hasFocus = false ;
UpdateImage ( true ) ;
Refresh ( false ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update time edit controls
2007-07-27 10:24:49 +02:00
void AudioDisplay : : UpdateTimeEditCtrls ( ) {
grid - > editBox - > StartTime - > SetTime ( curStartMS , true ) ;
grid - > editBox - > EndTime - > SetTime ( curEndMS , true ) ;
grid - > editBox - > Duration - > SetTime ( curEndMS - curStartMS , true ) ;
2008-03-13 19:55:09 +01:00
}
2009-07-29 07:43:02 +02:00