diff options
Diffstat (limited to 'muse2/share/scripts')
-rwxr-xr-x | muse2/share/scripts/ConstantLength | 77 | ||||
-rwxr-xr-x | muse2/share/scripts/DoNothing | 15 | ||||
-rwxr-xr-x | muse2/share/scripts/DoubleSpeed | 24 | ||||
-rw-r--r-- | muse2/share/scripts/Makefile.am | 11 | ||||
-rw-r--r-- | muse2/share/scripts/Makefile.in | 425 | ||||
-rw-r--r-- | muse2/share/scripts/README.txt | 36 | ||||
-rwxr-xr-x | muse2/share/scripts/RemoveShortEvents | 79 | ||||
-rwxr-xr-x | muse2/share/scripts/SwingQuantize1 | 105 |
8 files changed, 772 insertions, 0 deletions
diff --git a/muse2/share/scripts/ConstantLength b/muse2/share/scripts/ConstantLength new file mode 100755 index 00000000..f03addcd --- /dev/null +++ b/muse2/share/scripts/ConstantLength @@ -0,0 +1,77 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import sys,time +from PyQt4 import QtGui, QtCore + +class ScriptClass(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + + self.setWindowTitle('Constant length') + title = QtGui.QLabel('Make all events of length:') + self.titleEdit = QtGui.QComboBox() + self.titleEdit.addItem('1/1',1) + self.titleEdit.addItem('1/2',2) + self.titleEdit.addItem('1/4',4) + self.titleEdit.addItem('1/8',8) + self.titleEdit.addItem('1/16',16) + self.titleEdit.addItem('1/32',32) + self.titleEdit.addItem('1/64',64) + self.titleEdit.setCurrentIndex(4) + + button = QtGui.QPushButton("Execute") + self.connect(button, QtCore.SIGNAL('clicked()'), self.execute) + grid = QtGui.QGridLayout() + grid.setSpacing(3) + + grid.addWidget(title, 1, 0) + grid.addWidget(self.titleEdit, 1, 1) + + grid.addWidget(button, 2, 1) + + self.setLayout(grid) + self.resize(200, 100) + button.setFocus() + + def execute(self): + testFile = file(sys.argv[1],"r") + inputEvents = testFile.readlines() + testFile.close() + + beatDiv = self.titleEdit.itemData(self.titleEdit.currentIndex()).toInt()[0] + print "beatDiv=",beatDiv + eventLen=0 + #get beat length to calculate minimum length of event + for line in inputEvents: + if line.startswith('BEATLEN'): + tag,tick = line.split(' ') + eventLen=int(tick)/beatDiv*4 + break + + outputEvents=[] + #loop through events + for line in inputEvents: + + if line.startswith('NOTE'): + tag,tick,note,length,velocity = line.split(' ') + + length=eventLen + newLine=tag+" "+tick+" "+note+" "+str(length)+" "+velocity + outputEvents.append(newLine) + + else: + outputEvents.append(line) + + testFile = file(sys.argv[1],"w") + testFile.writelines(outputEvents) + testFile.close() + + quit() + + + +app = QtGui.QApplication(sys.argv) +qb = ScriptClass() +qb.show() +sys.exit(app.exec_()) diff --git a/muse2/share/scripts/DoNothing b/muse2/share/scripts/DoNothing new file mode 100755 index 00000000..a3d92c7d --- /dev/null +++ b/muse2/share/scripts/DoNothing @@ -0,0 +1,15 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import sys +testFile = file(sys.argv[1],"r") +inputEvents = testFile.readlines() +testFile.close() + +outputEvents=[] +#loop through events +for line in inputEvents: + outputEvents.append(line) + +testFile = file(sys.argv[1],"w") +testFile.writelines(outputEvents) +testFile.close() diff --git a/muse2/share/scripts/DoubleSpeed b/muse2/share/scripts/DoubleSpeed new file mode 100755 index 00000000..da6d0c2e --- /dev/null +++ b/muse2/share/scripts/DoubleSpeed @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# MusE external midi processing script +# By: Mathias Gyllengahm 2009 +# DoubleSpeed + +import sys,time +testFile = file(sys.argv[1],"r") +inputEvents = testFile.readlines() +testFile.close() + +outputEvents=[] +#loop through events +for line in inputEvents: + + if line.startswith('NOTE'): + tag,tick,pitch,length,velocity = line.split(' ') + newline = tag + " " + str(int(tick)/2) + " " + pitch + " " + length + " " + velocity + outputEvents.append(newline) + +testFile = file(sys.argv[1],"w") +testFile.writelines(outputEvents) +testFile.close() + diff --git a/muse2/share/scripts/Makefile.am b/muse2/share/scripts/Makefile.am new file mode 100644 index 00000000..0f2a9634 --- /dev/null +++ b/muse2/share/scripts/Makefile.am @@ -0,0 +1,11 @@ +EXTRA_DIST = DoNothing RemoveShortEvents DoubleSpeed ConstantLength SwingQuantize1 + +#musemidiscriptspkgdata_DATA = $(EXTRA_DIST) + +#musemidiscriptspkgdatadir = $(pkgdatadir)/scripts + +install-data-local: + mkdir -p $(DESTDIR)/$(pkgdatadir)/scripts/ + cp $(EXTRA_DIST) $(DESTDIR)/$(pkgdatadir)/scripts/ + chmod a+x $(DESTDIR)/$(pkgdatadir)/scripts/* + diff --git a/muse2/share/scripts/Makefile.in b/muse2/share/scripts/Makefile.in new file mode 100644 index 00000000..7fef85f6 --- /dev/null +++ b/muse2/share/scripts/Makefile.in @@ -0,0 +1,425 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = share/scripts +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal-include.m4 \ + $(top_srcdir)/m4/alsa.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOKSTYLE = @DOCBOOKSTYLE@ +DOCBOOKTARGETS = @DOCBOOKTARGETS@ +DOT = @DOT@ +DOTPATH = @DOTPATH@ +DOXYGEN = @DOXYGEN@ +DOXYGEN_TREEVIEW = @DOXYGEN_TREEVIEW@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLUIDSYNTHDIRS = @FLUIDSYNTHDIRS@ +FST_CFLAGS = @FST_CFLAGS@ +FST_LIBS = @FST_LIBS@ +Fluidsynth_CFLAGS = @Fluidsynth_CFLAGS@ +Fluidsynth_LIBS = @Fluidsynth_LIBS@ +GIVERTCAP = @GIVERTCAP@ +GREP = @GREP@ +HAVEDOT = @HAVEDOT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JACK_CFLAGS = @JACK_CFLAGS@ +JACK_LIBS = @JACK_LIBS@ +JADE = @JADE@ +LASH_CFLAGS = @LASH_CFLAGS@ +LASH_LIBS = @LASH_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LO_CFLAGS = @LO_CFLAGS@ +LO_LIBS = @LO_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MUSECXXFLAGS = @MUSECXXFLAGS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NSGMLS = @NSGMLS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCH = @PCH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_LIB = @PYTHON_LIB@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +QTDIR_BIN = @QTDIR_BIN@ +QTDIR_INC = @QTDIR_INC@ +QT_LIBS = @QT_LIBS@ +RANLIB = @RANLIB@ +SAMPLERATE_CFLAGS = @SAMPLERATE_CFLAGS@ +SAMPLERATE_LIBS = @SAMPLERATE_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ +SNDFILE_LIBS = @SNDFILE_LIBS@ +STRIP = @STRIP@ +SUIDBUILD = @SUIDBUILD@ +SUIDINSTALL = @SUIDINSTALL@ +USE_SSE = @USE_SSE@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +have_docbook = @have_docbook@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +synth_fluid = @synth_fluid@ +synth_fluidsynth = @synth_fluidsynth@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = DoNothing RemoveShortEvents DoubleSpeed ConstantLength SwingQuantize1 +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu share/scripts/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu share/scripts/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-data-local + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-data-local install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +#musemidiscriptspkgdata_DATA = $(EXTRA_DIST) + +#musemidiscriptspkgdatadir = $(pkgdatadir)/scripts + +install-data-local: + mkdir -p $(DESTDIR)/$(pkgdatadir)/scripts/ + cp $(EXTRA_DIST) $(DESTDIR)/$(pkgdatadir)/scripts/ + chmod a+x $(DESTDIR)/$(pkgdatadir)/scripts/* + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/muse2/share/scripts/README.txt b/muse2/share/scripts/README.txt new file mode 100644 index 00000000..8490dd69 --- /dev/null +++ b/muse2/share/scripts/README.txt @@ -0,0 +1,36 @@ +MusE midi event scripting format 0.5 + +Some information for the budding script writer, here is some info +about the format currently used. + +Scripts can be put in two different dirs. +<install_path>/share/muse/scripts +for scripts bundled +or $HOME/.muse/scripts +for user created scripts + +There are two main requirements on scripts. + +1. a script must have the executable flag set, that is, it must be considered +an executable from the perspective of the operating system. +2. a script shall take an input file as argument and will update this +file with the sought output. + +The tags that may occur in the file sent to the script are: +PARTLEN <len in ticks> +BEATLEN <len in ticks> +QUANTLEN <len in ticks> +NOTE <tick> <pitch> <len in ticks> <velocity> +CONTROLLER <tick> <a> <b> <c> + +PARTLEN, BEATLEN and QUANTLEN are there for informational purposes, to +make some transformations possible. e.g. quantization, beat delay. + +NOTE and CONTROLLER are the ones that are read back into MusE when the filter +stops executing. These may be manipulated, removed or multiplied as seen +fit by the filter. +-- Note that it is a good idea to just pass on the lines your script is not +interested in, otherwise data may unintentionally be removed -- + +A short example in pyton that does nothing but pass on output from input +to output is available in script DoNothing diff --git a/muse2/share/scripts/RemoveShortEvents b/muse2/share/scripts/RemoveShortEvents new file mode 100755 index 00000000..cc6735b2 --- /dev/null +++ b/muse2/share/scripts/RemoveShortEvents @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# MusE external midi processing script +# By: Robert Jonsson 2009 +# RemoveShortEvents + +import sys,time +from PyQt4 import QtGui, QtCore + +class RemoveShortEvents(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + + self.setWindowTitle('RemoveShortEvents') + + title = QtGui.QLabel('Remove events shorter than:') + self.timeEdit = QtGui.QComboBox() + self.timeEdit.addItem('1/1',1) + self.timeEdit.addItem('1/2',2) + self.timeEdit.addItem('1/4',4) + self.timeEdit.addItem('1/8',8) + self.timeEdit.addItem('1/16',16) + self.timeEdit.addItem('1/32',32) + self.timeEdit.setCurrentIndex(3) + + button = QtGui.QPushButton("Execute") + self.connect(button, QtCore.SIGNAL('clicked()'), self.execute) + + grid = QtGui.QGridLayout() + grid.setSpacing(3) + + grid.addWidget(title, 1, 0) + grid.addWidget(self.timeEdit, 1, 1) + + grid.addWidget(button, 2, 1) + + self.setLayout(grid) + self.resize(200, 100) + button.setFocus() + + def execute(self): + testFile = file(sys.argv[1],"r") + inputEvents = testFile.readlines() + testFile.close() + + beatDiv = int(self.timeEdit.itemData(self.timeEdit.currentIndex()).toInt()[0]) + minSize=0 # fill in when we get the beat size value + outputEvents=[] + + #get beat length to calculate minimum length of event + for line in inputEvents: + if line.startswith('BEATLEN'): + tag,tick = line.split(' ') + minSize=int(tick)/beatDiv + break + #loop through events + for line in inputEvents: + if line.startswith('NOTE'): + tag,tick,note,length,velocity = line.split(' ') + if int(length) > minSize: # only append long enough events + outputEvents.append(line) + + else: + outputEvents.append(line) + + + testFile = file(sys.argv[1],"w") + testFile.writelines(outputEvents) + testFile.close() + + + quit() + + + +app = QtGui.QApplication(sys.argv) +qb = RemoveShortEvents() +qb.show() +sys.exit(app.exec_()) diff --git a/muse2/share/scripts/SwingQuantize1 b/muse2/share/scripts/SwingQuantize1 new file mode 100755 index 00000000..11fded84 --- /dev/null +++ b/muse2/share/scripts/SwingQuantize1 @@ -0,0 +1,105 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# MusE external midi processing script +# By: Robert Jonsson 2009 +# Quantize + +import sys,time +from PyQt4 import QtGui, QtCore +import random + +class Quantize(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + + self.setWindowTitle('Swing quantize V1') + + + self.beatEdit = QtGui.QComboBox() + self.beatEdit.addItem('1/1',1) + self.beatEdit.addItem('1/2',2) + self.beatEdit.addItem('1/4',4) + self.beatEdit.addItem('1/8',8) + self.beatEdit.addItem('1/16',16) + self.beatEdit.addItem('1/32',32) + self.beatEdit.setCurrentIndex(2) + self.spreadEdit = QtGui.QLineEdit() + self.spreadEdit.setText('10') + + button = QtGui.QPushButton("Execute") + self.connect(button, QtCore.SIGNAL('clicked()'), self.execute) + + grid = QtGui.QGridLayout() + grid.setSpacing(3) + + grid.addWidget(QtGui.QLabel('Beat granularity:'), 1, 0) + grid.addWidget(self.beatEdit, 1, 1) + grid.addWidget(QtGui.QLabel('Spread/Swing(ticks)'), 2, 0) + grid.addWidget(self.spreadEdit, 2, 1) + grid.addWidget(button, 3, 1) + + self.setLayout(grid) + self.resize(200, 100) + button.setFocus() + + def execute(self): + testFile = file(sys.argv[1],"r") + inputEvents = testFile.readlines() + testFile.close() + + beatDiv = self.beatEdit.itemData(self.beatEdit.currentIndex()).toInt()[0] + minSize=0 # fill in when we get the beat size value + outputEvents=[] + quantLen=0 + + #get beat length to calculate minimum length of event + for line in inputEvents: + if line.startswith('BEATLEN'): + tag,tick = line.split(' ') + beatLen=int(tick) + quantLen=int(tick)/beatDiv*4 + print "quantLen=%d beatDiv=%d"%(quantLen, beatDiv) + print line.strip() + #loop through events and quantize to the given beat + eventList=[] + for line in inputEvents: + if line.startswith('NOTE'): + tag,tick,pitch,length,velocity = line.split(' ') + + # over quantize + lowerBound=(int(tick)/quantLen)*quantLen + upperBound=lowerBound+quantLen + lowDiff=int(tick)-lowerBound + highDiff=upperBound - int(tick) + if( lowDiff < highDiff): + newTick=lowerBound + else: + newTick=upperBound + + # apply swing factor to every other 8 beat + print "float =%f int = %d"%((float(newTick+beatLen)) / beatLen/2,((newTick+beatLen))/beatLen/2) + if ((float(newTick+beatLen)) / beatLen/2 - ((newTick+beatLen))/beatLen/2) < 0.1: + print "adding swing to:",newTick + newTick=int(random.gauss(newTick,self.spreadEdit.text().toInt()[0])) + if (newTick < 0): + newTick=0 + + newLine="NOTE "+ str(newTick)+" " + pitch + " "+ length + " " + velocity + print "newLine:",newLine.strip() + outputEvents.append(newLine) + else: + outputEvents.append(line) + + + + testFile = file(sys.argv[1],"w") + testFile.writelines(outputEvents) + testFile.close() + + quit() + + +app = QtGui.QApplication(sys.argv) +qb = Quantize() +qb.show() +sys.exit(app.exec_()) |