# HG changeset patch # User Chris Cannam # Date 1553774219 0 # Node ID 37bba98a18eb856547a7319275847b3e7c40d80a # Parent 9ba15c8260f64fb7a1e5a2292323e4becaa62381# Parent 0395990722bb4d7c03a6b01ba2a9688845ee77c0 Merge from branch osc-script diff -r 9ba15c8260f6 -r 37bba98a18eb main/OSCHandler.cpp --- a/main/OSCHandler.cpp Fri Mar 22 17:49:36 2019 +0000 +++ b/main/OSCHandler.cpp Thu Mar 28 11:56:59 2019 +0000 @@ -40,8 +40,6 @@ SVDEBUG << "OSCHandler: method = \"" << message.getMethod() << "\"" << endl; - // This large function should really be abstracted out. - if (message.getMethod() == "open") { if (message.getArgCount() == 1 && diff -r 9ba15c8260f6 -r 37bba98a18eb main/main.cpp --- a/main/main.cpp Fri Mar 22 17:49:36 2019 +0000 +++ b/main/main.cpp Thu Mar 28 11:56:59 2019 +0000 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -90,6 +91,8 @@ \section model Data sources: the Model hierarchy +***!!! todo: update this + A Model is something containing, or knowing how to obtain, data. For example, WaveFileModel is a model that knows how to get data @@ -238,12 +241,6 @@ svSystemSpecificInitialisation(); -#ifdef Q_WS_X11 -#if QT_VERSION >= 0x040500 -// QApplication::setGraphicsSystem("raster"); -#endif -#endif - #ifdef Q_OS_MAC if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) { // Fix for OS/X 10.9 font problem @@ -253,7 +250,51 @@ SVApplication application(argc, argv); + QApplication::setOrganizationName("sonic-visualiser"); + QApplication::setOrganizationDomain("sonicvisualiser.org"); + QApplication::setApplicationName(QApplication::tr("Sonic Visualiser")); + QApplication::setApplicationVersion(SV_VERSION); + + //!!! todo hand-update translations + QCommandLineParser parser; + parser.setApplicationDescription(QApplication::tr("Sonic Visualiser is a program for viewing and exploring audio data\nfor semantic music analysis and annotation.")); + parser.addHelpOption(); + parser.addVersionOption(); + + parser.addOptions({ + { "no-audio", QApplication::tr + ("Do not attempt to open an audio output device.") }, + { "no-osc", QApplication::tr + ("Do not provide an Open Sound Control port for remote control.") }, + { "no-splash", QApplication::tr + ("Do not show a splash screen.") }, + { "osc-script", QApplication::tr + ("Batch run the OSC script found in the given file. Scripts consist of /command arg1 arg2 ... OSC control lines, optionally interleaved with numbers to specify pauses in seconds."), + "osc.txt" } + }); + + parser.addPositionalArgument + ("[ ...]", QApplication::tr("One or more Sonic Visualiser (.sv) and audio files may be provided.")); + QStringList args = application.arguments(); + if (!parser.parse(args)) { + if (parser.unknownOptionNames().contains("?")) { + // QCommandLineParser only understands -? for help on Windows, + // but we historically accepted it everywhere - provide this + // backward compatibility + parser.showHelp(); + } + } + + parser.process(args); + + bool audioOutput = !(parser.isSet("no-audio")); + bool oscSupport = !(parser.isSet("no-osc")); + bool showSplash = !(parser.isSet("no-splash")); + + args = parser.positionalArguments(); + + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); signal(SIGINT, signalHandler); signal(SIGTERM, signalHandler); @@ -263,24 +304,6 @@ signal(SIGQUIT, signalHandler); #endif - bool audioOutput = true; - bool oscSupport = true; - - if (args.contains("--help") || args.contains("-h") || args.contains("-?")) { - cerr << QApplication::tr( - "\nSonic Visualiser is a program for viewing and exploring audio data\nfor semantic music analysis and annotation.\n\nUsage:\n\n %1 [--no-audio] [--no-osc] [ ...]\n\n --no-audio: Do not attempt to open an audio output device\n --no-osc: Do not provide an Open Sound Control port for remote control\n : One or more Sonic Visualiser (.sv) and audio files may be provided.\n").arg(argv[0]) << endl; - exit(2); - } - - if (args.contains("--no-audio")) audioOutput = false; - if (args.contains("--no-osc")) oscSupport = false; - - QApplication::setOrganizationName("sonic-visualiser"); - QApplication::setOrganizationDomain("sonicvisualiser.org"); - QApplication::setApplicationName(QApplication::tr("Sonic Visualiser")); - - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - SVSplash *splash = nullptr; QSettings settings; @@ -293,7 +316,7 @@ settings.endGroup(); settings.beginGroup("Preferences"); - if (settings.value("show-splash", true).toBool()) { + if (showSplash && settings.value("show-splash", true).toBool()) { splash = new SVSplash(); splash->show(); QTimer::singleShot(5000, splash, SLOT(hide())); @@ -411,7 +434,11 @@ for (QStringList::iterator i = args.begin(); i != args.end(); ++i) { - if (i == args.begin()) continue; + // Note QCommandLineParser has now pulled out argv[0] and all + // the options, so in theory everything here from the very + // first arg should be relevant. But let's reject names + // starting with "-" just in case. + if (i->startsWith('-')) continue; QString path = *i; @@ -419,7 +446,8 @@ application.handleFilepathArgument(path, splash); } - for (QStringList::iterator i = application.m_filepathQueue.begin(); i != application.m_filepathQueue.end(); ++i) { + for (QStringList::iterator i = application.m_filepathQueue.begin(); + i != application.m_filepathQueue.end(); ++i) { QString path = *i; application.handleFilepathArgument(path, splash); } @@ -439,6 +467,11 @@ settings.endGroup(); #endif + QString scriptFile = parser.value("osc-script"); + if (scriptFile != "") { + gui->cueOSCScript(scriptFile); + } + int rv = application.exec(); gui->hide(); diff -r 9ba15c8260f6 -r 37bba98a18eb misc/test-session-export.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/test-session-export.sh Thu Mar 28 11:56:59 2019 +0000 @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Test that loading and re-saving a session does not change its contents +# Must be run from same directory as the SV binary + +set -e + +session="$1" + +set -u + +sv="./sonic-visualiser" +if [ ! -x "$sv" ]; then + echo "This script must be run from the directory containing the sonic-visualiser binary" 1>&2 + exit 1 +fi + +if ! xmllint --version 2>/dev/null ; then + echo "Can't find required xmllint program (from libxml2 distribution)" 1>&2 + exit 1 +fi + +version=$("$sv" -v 2>&1) +adequate=no +case "$version" in + [012].*) ;; + 3.[012]) ;; + 3.[012].*) ;; + [1-9]*) adequate=yes ;; + *) echo "Failed to query Sonic Visualiser version" 1>&2 + exit 1 ;; +esac +if [ "$adequate" = "no" ]; then + echo "Sonic Visualiser version must be at least 3.3 (supporting --osc-script option)" 1>&2 + exit 1 +fi + +if [ -z "$session" ]; then + echo "Usage: $0 " 1>&2 + exit 2 +fi + +if [ ! -f "$session" ]; then + echo "Session file $session not found" 1>&2 + exit 1 +fi + +tmpdir=$(mktemp -d) +trap "rm -rf $tmpdir" 0 + +input="$tmpdir/input.sv" +inxml="$tmpdir/input.xml" +output="$tmpdir/output.sv" +outxml="$tmpdir/output.xml" + +cp "$session" "$input" + +cat > "$tmpdir/script" <&2 + exit 1 +fi + +bunzip2 -c "$input" | xmllint --format - > "$inxml" +bunzip2 -c "$output" | xmllint --format - > "$outxml" + +sdiff -w 140 "$inxml" "$outxml" + diff -r 9ba15c8260f6 -r 37bba98a18eb repoint-lock.json --- a/repoint-lock.json Fri Mar 22 17:49:36 2019 +0000 +++ b/repoint-lock.json Thu Mar 28 11:56:59 2019 +0000 @@ -4,13 +4,13 @@ "pin": "b650289c47b4" }, "svcore": { - "pin": "a77a7e8c085c" + "pin": "69ab62d378bf" }, "svgui": { "pin": "09d008b5c8f4" }, "svapp": { - "pin": "365c61ac7680" + "pin": "8ad6327b01cc" }, "checker": { "pin": "5c60e26e16ca" diff -r 9ba15c8260f6 -r 37bba98a18eb repoint-project.json --- a/repoint-project.json Fri Mar 22 17:49:36 2019 +0000 +++ b/repoint-project.json Thu Mar 28 11:56:59 2019 +0000 @@ -17,7 +17,7 @@ "svcore": { "vcs": "hg", "service": "soundsoftware", - "branch": "single-point" + "branch": "osc-script" }, "svgui": { "vcs": "hg", @@ -27,7 +27,7 @@ "svapp": { "vcs": "hg", "service": "soundsoftware", - "branch": "single-point" + "branch": "osc-script" }, "checker": { "vcs": "hg",