Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Merge pull request #1071 from shun-iwasawa/fix_flipconsole_connection

Jeremy Bullock9bc9a3315af2
diff --cc toonz/sources/toonz/comboviewerpane.cpp
index 894070f8a,af1fc7063..5caadc5b3
--- a/toonz/sources/toonz/comboviewerpane.cpp
+++ b/toonz/sources/toonz/comboviewerpane.cpp
@@@ -807,56 -786,6 +807,52 @@@ bool ComboViewerPanel::isFrameAlreadyCa
//-----------------------------------------------------------------------------
void ComboViewerPanel::onPreferenceChanged(const QString &prefName) {
- // if no name specified (on showEvent), then process all updates
- if (prefName == "BlankCount" || prefName == "BlankColor" ||
- prefName.isEmpty())
- m_flipConsole->onPreferenceChanged();
-
+ m_flipConsole->onPreferenceChanged(prefName);
StyleShortcutSwitchablePanel::onPreferenceChanged(prefName);
}
+
+void ComboViewerPanel::playAudioFrame(int frame) {
+ if (m_first) {
+ m_first = false;
+ m_fps = TApp::instance()
+ ->getCurrentScene()
+ ->getScene()
+ ->getProperties()
+ ->getOutputProperties()
+ ->getFrameRate();
+ m_samplesPerFrame = m_sound->getSampleRate() / abs(m_fps);
+ }
+ if (!m_sound) return;
+ m_viewerFps = m_flipConsole->getCurrentFps();
+ double s0 = frame * m_samplesPerFrame, s1 = s0 + m_samplesPerFrame;
+ // make the sound stop if the viewerfps is higher so the next sound can play
+ // on time.
+ if (m_fps < m_viewerFps)
+ TApp::instance()->getCurrentXsheet()->getXsheet()->stopScrub();
+ TApp::instance()->getCurrentXsheet()->getXsheet()->play(m_sound, s0, s1,
+ false);
+}
+
+bool ComboViewerPanel::hasSoundtrack() {
+ if (m_sound != NULL) {
+ m_sound = NULL;
+ m_hasSoundtrack = false;
+ m_first = true;
+ }
+ TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
+ TXsheet::SoundProperties *prop = new TXsheet::SoundProperties();
+ m_sound = xsheetHandle->getXsheet()->makeSound(prop);
+ if (m_sound == NULL) {
+ m_hasSoundtrack = false;
+ return false;
+ } else {
+ m_hasSoundtrack = true;
+ return true;
+ }
+}
+
+void ComboViewerPanel::onButtonPressed(FlipConsole::EGadget button) {
+ if (button == FlipConsole::eSound) {
+ m_playSound = !m_playSound;
+ }
+}