Aegisub/aegisub/src/audio_display.h

284 lines
5.5 KiB
C
Raw Normal View History

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 Project http://www.aegisub.org/
2006-01-16 22:02:54 +01:00
//
// $Id$
/// @file audio_display.h
/// @see audio_display.cpp
/// @ingroup audio_ui
///
2006-01-16 22:02:54 +01:00
#pragma once
2006-01-16 22:02:54 +01:00
#ifndef AGI_PRE
#include <stdint.h>
#include <wx/bitmap.h>
#include <wx/scrolbar.h>
#include <wx/window.h>
#endif
#include "audio_renderer_spectrum.h"
2006-01-16 22:02:54 +01:00
class AudioPlayer;
class AudioProvider;
2006-01-16 22:02:54 +01:00
class AssDialogue;
class SubtitlesGrid;
class AudioBox;
class AudioKaraoke;
class VideoProvider;
class FrameMain;
2006-01-16 22:02:54 +01:00
/// DOCME
/// @class AudioDisplay
/// @brief DOCME
///
/// DOCME
2006-01-16 22:02:54 +01:00
class AudioDisplay: public wxWindow {
friend class FrameMain;
2006-01-16 22:02:54 +01:00
private:
/// DOCME
2006-01-16 22:02:54 +01:00
SubtitlesGrid *grid;
/// DOCME
2006-01-16 22:02:54 +01:00
int line_n;
/// DOCME
2006-01-16 22:02:54 +01:00
AssDialogue *dialogue;
/// DOCME
AudioSpectrum *spectrumRenderer;
/// DOCME
2006-01-16 22:02:54 +01:00
wxBitmap *origImage;
/// DOCME
2006-01-16 22:02:54 +01:00
wxBitmap *spectrumDisplay;
/// DOCME
wxBitmap *spectrumDisplaySelected;
/// DOCME
int64_t PositionSample;
/// DOCME
2006-01-16 22:02:54 +01:00
float scale;
/// DOCME
2006-01-16 22:02:54 +01:00
int samples;
/// DOCME
int64_t Position;
/// DOCME
2006-01-16 22:02:54 +01:00
int samplesPercent;
/// DOCME
2006-01-16 22:02:54 +01:00
int oldCurPos;
/// DOCME
2006-01-16 22:02:54 +01:00
bool hasFocus;
/// DOCME
2006-01-16 22:02:54 +01:00
bool blockUpdate;
/// DOCME
2006-01-16 22:02:54 +01:00
bool dontReadTimes;
/// DOCME
bool playingToEnd;
2006-01-16 22:02:54 +01:00
/// DOCME
bool needImageUpdate;
/// DOCME
bool needImageUpdateWeak;
/// DOCME
2006-01-16 22:02:54 +01:00
bool hasSel;
/// DOCME
2006-01-16 22:02:54 +01:00
bool hasKaraoke;
/// DOCME
2006-01-16 22:02:54 +01:00
bool diagUpdated;
/// DOCME
bool holding;
/// DOCME
bool draggingScale;
/// DOCME
int64_t selStart;
/// DOCME
int64_t selEnd;
/// DOCME
int64_t lineStart;
/// DOCME
int64_t lineEnd;
/// DOCME
int64_t selStartCap;
/// DOCME
int64_t selEndCap;
/// DOCME
2006-01-16 22:02:54 +01:00
int hold;
/// DOCME
2006-01-16 22:02:54 +01:00
int lastX;
/// DOCME
int lastDragX;
/// DOCME
2006-01-16 22:02:54 +01:00
int curStartMS;
/// DOCME
2006-01-16 22:02:54 +01:00
int curEndMS;
/// DOCME
2006-01-16 22:02:54 +01:00
int holdSyl;
/// DOCME
2006-01-16 22:02:54 +01:00
int *peak;
/// DOCME
2006-01-16 22:02:54 +01:00
int *min;
void OnPaint(wxPaintEvent &event);
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();
void DrawTimescale(wxDC &dc);
void DrawKeyframes(wxDC &dc);
void DrawInactiveLines(wxDC &dc);
2006-01-16 22:02:54 +01:00
void DrawWaveform(wxDC &dc,bool weak);
void DrawSpectrum(wxDC &dc,bool weak);
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);
int GetBoundarySnap(int x,int range,bool shiftHeld,bool start=true);
void DoUpdateImage();
2006-01-16 22:02:54 +01:00
public:
/// DOCME
AudioProvider *provider;
/// DOCME
AudioPlayer *player;
/// DOCME
2006-01-16 22:02:54 +01:00
bool NeedCommit;
/// DOCME
2006-01-16 22:02:54 +01:00
bool loaded;
/// DOCME
bool temporary;
/// DOCME
/// DOCME
2006-01-16 22:02:54 +01:00
int w,h;
/// DOCME
2006-01-16 22:02:54 +01:00
AudioBox *box;
/// DOCME
2006-01-16 22:02:54 +01:00
AudioKaraoke *karaoke;
/// DOCME
2006-01-16 22:02:54 +01:00
wxScrollBar *ScrollBar;
/// DOCME
2006-01-16 22:02:54 +01:00
wxTimer UpdateTimer;
AudioDisplay(wxWindow *parent);
2006-01-16 22:02:54 +01:00
~AudioDisplay();
void UpdateImage(bool weak=false);
void Update();
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();
void SetDialogue(SubtitlesGrid *_grid=NULL,AssDialogue *diag=NULL,int n=-1);
void MakeDialogueVisible(bool force=false);
void ChangeLine(int delta, bool block=false);
void Next(bool play=true);
void Prev(bool play=true);
void UpdateTimeEditCtrls();
void CommitChanges(bool nextLine=false);
void AddLead(bool in,bool out);
void SetFile(wxString file);
void SetFromVideo();
void Reload();
void Play(int start,int end);
void Stop();
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);
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);
DECLARE_EVENT_TABLE()
2006-01-16 22:02:54 +01:00
};
///////
// IDs
enum {
Audio_Update_Timer = 1700
};