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.
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// AEGISUB
|
|
|
|
//
|
|
|
|
// Website: http://aegisub.cellosoft.com
|
|
|
|
// Contact: mailto:zeratul@cellosoft.com
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef AUDIO_DISPLAY_H
|
|
|
|
#define AUDIO_DISPLAY_H
|
|
|
|
|
|
|
|
|
|
|
|
///////////
|
|
|
|
// Headers
|
|
|
|
#include <wx/wxprec.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/window.h>
|
|
|
|
#include <wx/bitmap.h>
|
2007-08-31 16:11:35 +02:00
|
|
|
#include <stdint.h>
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "audio_provider.h"
|
2006-02-25 08:41:18 +01:00
|
|
|
#include "audio_player.h"
|
2007-01-07 05:44:11 +01:00
|
|
|
#include "audio_spectrum.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
//////////////
|
|
|
|
// Prototypes
|
|
|
|
class AssDialogue;
|
2006-07-04 08:13:54 +02:00
|
|
|
class StreamAudioProvider;
|
2006-01-16 22:02:54 +01:00
|
|
|
class SubtitlesGrid;
|
|
|
|
class AudioBox;
|
|
|
|
class AudioKaraoke;
|
2006-04-15 00:35:39 +02:00
|
|
|
class VideoProvider;
|
2006-12-30 23:08:23 +01:00
|
|
|
class FrameMain;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2006-02-25 08:41:18 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
/////////////////
|
|
|
|
// Display class
|
|
|
|
class AudioDisplay: public wxWindow {
|
2006-12-30 23:08:23 +01:00
|
|
|
friend class FrameMain;
|
2006-01-16 22:02:54 +01:00
|
|
|
private:
|
|
|
|
SubtitlesGrid *grid;
|
|
|
|
int line_n;
|
|
|
|
AssDialogue *dialogue;
|
|
|
|
|
2007-01-07 05:44:11 +01:00
|
|
|
AudioSpectrum *spectrumRenderer;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
wxBitmap *origImage;
|
|
|
|
wxBitmap *spectrumDisplay;
|
2007-01-07 05:44:11 +01:00
|
|
|
wxBitmap *spectrumDisplaySelected;
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t PositionSample;
|
2006-01-16 22:02:54 +01:00
|
|
|
float scale;
|
|
|
|
int samples;
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t Position;
|
2006-01-16 22:02:54 +01:00
|
|
|
int samplesPercent;
|
|
|
|
int oldCurPos;
|
|
|
|
bool hasFocus;
|
|
|
|
bool blockUpdate;
|
|
|
|
bool dontReadTimes;
|
|
|
|
|
|
|
|
bool hasSel;
|
|
|
|
bool hasKaraoke;
|
|
|
|
bool diagUpdated;
|
2006-02-21 22:33:15 +01:00
|
|
|
bool holding;
|
2006-03-07 01:12:50 +01:00
|
|
|
bool draggingScale;
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t selStart;
|
|
|
|
int64_t selEnd;
|
|
|
|
int64_t lineStart;
|
|
|
|
int64_t lineEnd;
|
|
|
|
int64_t selStartCap;
|
|
|
|
int64_t selEndCap;
|
2006-01-16 22:02:54 +01:00
|
|
|
int hold;
|
|
|
|
int lastX;
|
2006-03-07 01:12:50 +01:00
|
|
|
int lastDragX;
|
2006-01-16 22:02:54 +01:00
|
|
|
int curStartMS;
|
|
|
|
int curEndMS;
|
|
|
|
int holdSyl;
|
|
|
|
|
|
|
|
int *peak;
|
|
|
|
int *min;
|
|
|
|
|
2006-07-04 07:10:29 +02:00
|
|
|
int scrubTime;
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t scrubLastPos;
|
2006-07-04 07:10:29 +02:00
|
|
|
bool scrubbing;
|
2006-07-07 00:39:58 +02:00
|
|
|
int scrubLastRate;
|
2006-07-04 07:10:29 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
void OnPaint(wxPaintEvent &event);
|
2007-01-07 05:44:11 +01:00
|
|
|
void OnMouseEvent(wxMouseEvent &event);
|
2006-01-16 22:02:54 +01:00
|
|
|
void OnSize(wxSizeEvent &event);
|
|
|
|
void OnUpdateTimer(wxTimerEvent &event);
|
|
|
|
void OnKeyDown(wxKeyEvent &event);
|
|
|
|
void OnGetFocus(wxFocusEvent &event);
|
|
|
|
void OnLoseFocus(wxFocusEvent &event);
|
|
|
|
|
|
|
|
void UpdateSamples();
|
|
|
|
void Reset();
|
2007-04-07 04:39:18 +02:00
|
|
|
void DrawTimescale(wxDC &dc);
|
|
|
|
void DrawKeyframes(wxDC &dc);
|
2007-04-13 03:29:05 +02:00
|
|
|
void DrawInactiveLines(wxDC &dc);
|
2006-01-16 22:02:54 +01:00
|
|
|
void DrawWaveform(wxDC &dc,bool weak);
|
|
|
|
void DrawSpectrum(wxDC &dc,bool weak);
|
2007-08-31 16:11:35 +02:00
|
|
|
void GetDialoguePos(int64_t &start,int64_t &end,bool cap);
|
|
|
|
void GetKaraokePos(int64_t &start,int64_t &end,bool cap);
|
2006-01-16 22:02:54 +01:00
|
|
|
void UpdatePosition(int pos,bool IsSample=false);
|
|
|
|
|
2007-04-07 04:39:18 +02:00
|
|
|
int GetBoundarySnap(int x,int range,bool shiftHeld,bool start=true);
|
2007-01-06 05:19:00 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
public:
|
2006-02-25 08:41:18 +01:00
|
|
|
AudioProvider *provider;
|
2006-07-04 08:13:54 +02:00
|
|
|
StreamAudioProvider *scrubProvider;
|
2006-02-25 08:41:18 +01:00
|
|
|
AudioPlayer *player;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
bool NeedCommit;
|
|
|
|
bool loaded;
|
2006-07-01 08:32:11 +02:00
|
|
|
bool temporary;
|
2006-01-16 22:02:54 +01:00
|
|
|
int w,h;
|
|
|
|
AudioBox *box;
|
|
|
|
AudioKaraoke *karaoke;
|
|
|
|
wxScrollBar *ScrollBar;
|
|
|
|
wxTimer UpdateTimer;
|
|
|
|
|
2007-01-21 18:01:22 +01:00
|
|
|
AudioDisplay(wxWindow *parent);
|
2006-01-16 22:02:54 +01:00
|
|
|
~AudioDisplay();
|
|
|
|
|
|
|
|
void UpdateImage(bool weak=false);
|
|
|
|
void Update();
|
2007-01-06 07:14:35 +01:00
|
|
|
void RecreateImage();
|
2006-01-16 22:02:54 +01:00
|
|
|
void SetPosition(int pos);
|
|
|
|
void SetSamplesPercent(int percent,bool update=true,float pivot=0.5);
|
|
|
|
void SetScale(float scale);
|
|
|
|
void UpdateScrollbar();
|
2006-02-20 23:24:25 +01:00
|
|
|
void SetDialogue(SubtitlesGrid *_grid=NULL,AssDialogue *diag=NULL,int n=-1);
|
2007-04-10 04:55:23 +02:00
|
|
|
void MakeDialogueVisible(bool force=false);
|
|
|
|
void ChangeLine(int delta);
|
2007-07-27 10:24:49 +02:00
|
|
|
void Next(bool play=true);
|
|
|
|
void Prev(bool play=true);
|
2007-04-10 04:55:23 +02:00
|
|
|
|
2007-07-27 10:24:49 +02:00
|
|
|
void UpdateTimeEditCtrls();
|
2007-04-10 04:55:23 +02:00
|
|
|
void CommitChanges(bool nextLine=false);
|
|
|
|
void AddLead(bool in,bool out);
|
|
|
|
|
2007-06-20 04:18:55 +02:00
|
|
|
void SetFile(wxString file);
|
2007-04-10 04:55:23 +02:00
|
|
|
void SetFromVideo();
|
|
|
|
void Reload();
|
|
|
|
|
|
|
|
void Play(int start,int end);
|
|
|
|
void Stop();
|
2006-02-20 23:24:25 +01:00
|
|
|
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t GetSampleAtX(int x);
|
|
|
|
int GetXAtSample(int64_t n);
|
|
|
|
int GetMSAtX(int64_t x);
|
|
|
|
int GetXAtMS(int64_t ms);
|
|
|
|
int GetMSAtSample(int64_t x);
|
|
|
|
int64_t GetSampleAtMS(int64_t ms);
|
2006-02-20 23:24:25 +01:00
|
|
|
int GetSyllableAtX(int x);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
void GetTimesDialogue(int &start,int &end);
|
|
|
|
void GetTimesSelection(int &start,int &end);
|
|
|
|
void SetSelection(int start, int end);
|
|
|
|
|
2006-01-19 11:33:56 +01:00
|
|
|
DECLARE_EVENT_TABLE()
|
2006-01-16 22:02:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////
|
|
|
|
// IDs
|
|
|
|
enum {
|
|
|
|
Audio_Update_Timer = 1700
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|