2010-12-08 04:36:10 +01:00
|
|
|
// Copyright (c) 2010, Niels Martin Hansen
|
|
|
|
// 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/
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file audio_timing.h
|
|
|
|
/// @brief Construction-functions for timing controller objects
|
|
|
|
/// @ingroup audio_ui
|
|
|
|
|
|
|
|
class AssDialogue;
|
2010-12-08 09:10:00 +01:00
|
|
|
class AssFile;
|
2011-09-28 21:44:07 +02:00
|
|
|
class AssKaraoke;
|
2011-11-18 23:56:45 +01:00
|
|
|
class AudioRenderingStyleRanges;
|
2011-09-28 21:44:07 +02:00
|
|
|
namespace agi { struct Context; }
|
2010-12-08 04:36:10 +01:00
|
|
|
|
2011-09-28 21:44:07 +02:00
|
|
|
#include "audio_controller.h"
|
2011-07-15 06:04:13 +02:00
|
|
|
#include "selection_controller.h"
|
|
|
|
|
2010-12-31 22:02:42 +01:00
|
|
|
#include <libaegisub/signal.h>
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
/// @class AudioTimingController
|
|
|
|
/// @brief Base class for objects controlling audio timing
|
|
|
|
///
|
2011-01-16 08:14:53 +01:00
|
|
|
/// There is just one active audio timing controller at a time per audio
|
|
|
|
/// controller. The timing controller manages the timing mode and supplies
|
|
|
|
/// markers that can be manipulated to the audio display, as well as the
|
|
|
|
/// current selection.
|
2010-12-08 04:36:10 +01:00
|
|
|
///
|
2011-01-16 08:14:53 +01:00
|
|
|
/// The timing controller must then be sent the marker drag events as well as
|
|
|
|
/// clicks in empty areas of the audio display.
|
2011-09-15 07:16:26 +02:00
|
|
|
class AudioTimingController : public AudioMarkerProvider, public AudioLabelProvider {
|
2010-12-08 09:09:16 +01:00
|
|
|
protected:
|
|
|
|
/// The primary playback range has changed, usually as a result of user interaction.
|
|
|
|
agi::signal::Signal<> AnnounceUpdatedPrimaryRange;
|
|
|
|
|
|
|
|
/// One or more rendering style ranges have changed in the timing controller.
|
|
|
|
agi::signal::Signal<> AnnounceUpdatedStyleRanges;
|
|
|
|
|
2010-12-08 04:36:10 +01:00
|
|
|
public:
|
|
|
|
/// @brief Get any warning message to show in the audio display
|
|
|
|
/// @return The warning message to show, may be empty if there is none
|
|
|
|
virtual wxString GetWarningMessage() const = 0;
|
|
|
|
|
|
|
|
/// @brief Get the sample range the user is most likely to want to see for the current state
|
|
|
|
/// @return A sample range
|
|
|
|
///
|
|
|
|
/// This is used for "bring working area into view" operations.
|
2010-12-08 09:09:16 +01:00
|
|
|
virtual SampleRange GetIdealVisibleSampleRange() const = 0;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
/// @brief Get the primary playback range
|
|
|
|
/// @return A sample range
|
|
|
|
///
|
2011-01-16 08:14:59 +01:00
|
|
|
/// Get the sample range the user is most likely to want to play back
|
|
|
|
/// currently.
|
2010-12-08 09:09:16 +01:00
|
|
|
virtual SampleRange GetPrimaryPlaybackRange() const = 0;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
2011-11-18 23:56:45 +01:00
|
|
|
/// @brief Get all rendering style ranges
|
2012-01-08 02:37:12 +01:00
|
|
|
/// @param[out] ranges Rendering ranges will be added to this
|
2011-11-18 23:56:45 +01:00
|
|
|
virtual void GetRenderingStyles(AudioRenderingStyleRanges &ranges) const = 0;
|
|
|
|
|
2010-12-08 04:36:10 +01:00
|
|
|
/// @brief Go to next timing unit
|
|
|
|
///
|
2011-01-16 08:14:59 +01:00
|
|
|
/// Advances the timing controller cursor to the next timing unit, for
|
|
|
|
/// example the next dialogue line or the next karaoke syllable.
|
2010-12-08 04:36:10 +01:00
|
|
|
virtual void Next() = 0;
|
|
|
|
|
|
|
|
/// @brief Go to the previous timing unit
|
|
|
|
///
|
|
|
|
/// Rewinds the timing controller to the previous timing unit.
|
|
|
|
virtual void Prev() = 0;
|
|
|
|
|
|
|
|
/// @brief Commit all changes
|
|
|
|
///
|
|
|
|
/// Stores all changes permanently.
|
|
|
|
virtual void Commit() = 0;
|
|
|
|
|
|
|
|
/// @brief Revert all changes
|
|
|
|
///
|
|
|
|
/// Revert all changes to the last committed state.
|
|
|
|
virtual void Revert() = 0;
|
|
|
|
|
|
|
|
/// @brief Determine if a position is close to a draggable marker
|
|
|
|
/// @param sample The audio sample index to test
|
|
|
|
/// @param sensitivity Distance in samples to consider markers as nearby
|
|
|
|
/// @return True if a marker is close by the given sample, as defined by sensitivity
|
|
|
|
///
|
2011-01-16 08:14:59 +01:00
|
|
|
/// This is solely for hit-testing against draggable markers, for
|
|
|
|
/// controlling the mouse cursor.
|
2010-12-08 04:36:10 +01:00
|
|
|
virtual bool IsNearbyMarker(int64_t sample, int sensitivity) const = 0;
|
|
|
|
|
|
|
|
/// @brief The user pressed the left button down at an empty place in the audio
|
|
|
|
/// @param sample The audio sample index the user clicked
|
|
|
|
/// @param sensitivity Distance in samples to consider existing markers
|
2012-01-08 02:35:11 +01:00
|
|
|
/// @param snap_range Maximum snapping range in samples
|
2011-01-16 08:14:59 +01:00
|
|
|
/// @return An audio marker or 0. If a marker is returned and the user
|
|
|
|
/// starts dragging the mouse after pressing down the button, the returned
|
|
|
|
/// marker is being dragged.
|
2012-01-08 02:35:11 +01:00
|
|
|
virtual AudioMarker * OnLeftClick(int64_t sample, int sensitivity, int64_t snap_range) = 0;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
/// @brief The user pressed the right button down at an empty place in the audio
|
|
|
|
/// @param sample The audio sample index the user clicked
|
|
|
|
/// @param sensitivity Distance in samples to consider existing markers
|
2012-01-08 02:35:11 +01:00
|
|
|
/// @param snap_range Maximum snapping range in samples
|
2011-01-16 08:14:59 +01:00
|
|
|
/// @return An audio marker or 0. If a marker is returned and the user
|
|
|
|
/// starts dragging the mouse after pressing down the button, the returned
|
|
|
|
/// marker is being dragged.
|
2012-01-08 02:35:11 +01:00
|
|
|
virtual AudioMarker * OnRightClick(int64_t sample, int sensitivity, int64_t snap_range) = 0;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
/// @brief The user dragged a timing marker
|
|
|
|
/// @param marker The marker being dragged
|
|
|
|
/// @param new_position Sample position the marker was dragged to
|
2012-01-08 02:35:04 +01:00
|
|
|
/// @param snap_range Maximum snapping range in samples
|
2012-01-08 02:35:11 +01:00
|
|
|
virtual void OnMarkerDrag(AudioMarker *marker, int64_t new_position, int64_t snap_range) = 0;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
/// @brief Destructor
|
|
|
|
virtual ~AudioTimingController() { }
|
2010-12-08 09:09:16 +01:00
|
|
|
|
|
|
|
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedPrimaryRange, AddUpdatedPrimaryRangeListener)
|
|
|
|
DEFINE_SIGNAL_ADDERS(AnnounceUpdatedStyleRanges, AddUpdatedStyleRangesListener)
|
2010-12-08 04:36:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// @brief Create a standard dialogue audio timing controller
|
2011-09-28 21:44:44 +02:00
|
|
|
/// @param c Project context
|
|
|
|
AudioTimingController *CreateDialogueTimingController(agi::Context *c);
|
2011-09-28 21:44:07 +02:00
|
|
|
|
|
|
|
/// @brief Create a karaoke audio timing controller
|
|
|
|
/// @param c Project context
|
|
|
|
/// @param kara Karaoke model
|
|
|
|
AudioTimingController *CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed);
|