diff options
author | Robert Jonsson <spamatica@gmail.com> | 2010-10-13 19:34:22 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2010-10-13 19:34:22 +0000 |
commit | 8a2c2824a59d7644e13bc52c9a0ecbd641f21f95 (patch) | |
tree | 064ad3f2bf8daab0ad27b128abd86a9bbdb1e496 /muse2/utils | |
parent | a27706d9629e8b592cca4659f865b70adef24e6d (diff) |
new branch muse2, first checkin
Diffstat (limited to 'muse2/utils')
-rw-r--r-- | muse2/utils/Makefile.am | 5 | ||||
-rw-r--r-- | muse2/utils/Makefile.in | 420 | ||||
-rwxr-xr-x | muse2/utils/muse-find-unused-wavs | 64 | ||||
-rwxr-xr-x | muse2/utils/muse-song-convert.py | 740 |
4 files changed, 1229 insertions, 0 deletions
diff --git a/muse2/utils/Makefile.am b/muse2/utils/Makefile.am new file mode 100644 index 00000000..8197531c --- /dev/null +++ b/muse2/utils/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = muse-find-unused-wavs + +install-data-local: + cp $(EXTRA_DIST) $(DESTDIR)/$(bindir)/ + chmod a+x $(DESTDIR)/$(bindir)/$(EXTRA_DIST) diff --git a/muse2/utils/Makefile.in b/muse2/utils/Makefile.in new file mode 100644 index 00000000..8a9320a2 --- /dev/null +++ b/muse2/utils/Makefile.in @@ -0,0 +1,420 @@ +# 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 = utils +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 = muse-find-unused-wavs +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 utils/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu utils/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 + + +install-data-local: + cp $(EXTRA_DIST) $(DESTDIR)/$(bindir)/ + chmod a+x $(DESTDIR)/$(bindir)/$(EXTRA_DIST) + +# 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/utils/muse-find-unused-wavs b/muse2/utils/muse-find-unused-wavs new file mode 100755 index 00000000..a325e1e0 --- /dev/null +++ b/muse2/utils/muse-find-unused-wavs @@ -0,0 +1,64 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import os +import string +import shutil + +dirlist = os.listdir(".") + +wavs=[] + +print "muse-find-unused-wavs - check wav file usage in all *.med files in current dir." +print "" +print "This utility scans all med files in the current dir, maps their" +print "wave file usage to what is currently available in current dir." +print "The output is printed." +print "Files no longer used are moved to the subdir 'unused'" +print "Press enter to continue." +print "" +raw_input() + +for line in dirlist: + if (line.endswith( ".wav")): + #print "HA!", line + wavs.append(line) +print "====================================================" +print "====================================================" +print " These wave files were found in current directory:\n" +if wavs == []: + print "No files were found." + sys.exit(0) +else: + for f in wavs: + print f + +for line in dirlist: + if (line.endswith( ".med") ): + #print "HO!", line + med = file(line) + for line in med: + for wav in wavs: + if line.find(wav) != -1: + #print "found %s removing %s"%(line, wav) + wavs.remove(wav) + +print "====================================================" +print " These wave files were unused:\n" +if wavs == []: + print "None" +else: + for f in wavs: + print f + + print "moving to new subdir unused, press Enter to continue" + raw_input() + + try: + os.mkdir('unused') + except: + pass + for f in wavs: + shutil.move(f,'unused') +print "====================================================" +print "====================================================" + diff --git a/muse2/utils/muse-song-convert.py b/muse2/utils/muse-song-convert.py new file mode 100755 index 00000000..ff2f81b0 --- /dev/null +++ b/muse2/utils/muse-song-convert.py @@ -0,0 +1,740 @@ +#!/usr/bin/python +import sys +import os +import string + +version = "0.6" +########################################## +########################################## +# +# MusE song format converter +# +######################################### +######################################### + +# blocks to remove: +blocks = [ +["<segmentsize>","</segmentsize>"], +["<rtcTicks>","</rtcTicks>"], +["<useAlsa>", "</useAlsa>"], +["<useJack>", "</useJack>"], +["<extendedMidi>", "</extendedMidi>"], +["<midiExportDivision>", "</midiExportDivision>"], +["<font", "</font"], +["<theme>", "</theme>"], +["_font", "/>"], +["<show_page_no>","</show_page_no>"], +["<show_measure_no>","</show_measure_no>"], +["<paper_width>","</paper_width>"], +["<paper_height>","</paper_height>"], +["<top_margin>","</top_margin>"], +["<bottom_margin>","</bottom_margin>"], +["<left_margin>","</left_margin>"], +["<right_margin>","</right_margin>"], +["<bars_page>","</bars_page>"], +["<print_scale>","</print_scale>"], +["<show_track_name>","</show_track_name>"], +["<activityColor","</activityColor>"], +["<activityMode>","</activityMode>"], +["<score>","</score>"], +["<image>","</image>"], +["<part_type>","</part_type>"], +["<show_events>","</show_events>"], +["<grid>","</grid>"], +["<printer type","</printer>"], +["<bigtime visible","</bigtime>"], +["<transport visible","</transport>"], +["<audioInput>","</audioInput>"], +["<audioOutput","</audioOutput>"], +["<AudioInRoute>","</AudioInRoute>"], +["<track type=", "<track type="], +["</track", "</track"], +["<staff","</staff"], +["<noteQuant>","</noteQuant"], +["<restQuant>","</restQuant"], +["<midiThru>","</midiThru"], +["<splitpoint>","</splitpoint"], +] + +# To store array of audio groups +# input, group1,2,3,4 + master +AudioGroupTags = [ +"<channels>","<connect>","<volume>","<pan>", +"<mute>","<solo>","<prefader>","<off>"] +adata=[] +synths=[] +clips=[] +midiports=[] + +class MusEConvert: + def __init__(self): + self.insidePart = False + self.insideWaveTrack=False + self.currWaveTrackName="" + + # parse string and look for blocks to remove + def findAndSkipBlock(self, theFile, currLine): + for line in blocks: + if string.find(currLine , line[0]) > -1: + #print "Skipping %s"%line[0] + self.loopUntil(theFile, currLine, line[1]) + return True + return False + + # when a block has been found, loop until the end-tag. + def loopUntil(self, theFile, currLine, tagToFind): + loopEnd = False + if string.find(currLine , tagToFind) > -1: + loopEnd = True + while loopEnd == False: + line = inFile.readline() + if string.find(line, tagToFind) > -1: + loopEnd = True + + def fixComma(self, theFile, currLine): + newStr = string.replace(currLine , ",",".") + return newStr + + + def getSynth(self, theFile, currLine): + line = theFile.readline() # <class> + clas = self.getSimpleValue(line) + line = theFile.readline() # <name> + name = self.getSimpleValue(line) + line = theFile.readline() # <port> + port = self.getSimpleValue(line) + line = theFile.readline() # <guiVisible> + guiVisible = self.getSimpleValue(line) + + stateInfo = [] + line = theFile.readline() + notFoundStateEnd= True + if string.find(line , "<midistate") > -1: + notFoundStateEnd = True + line = theFile.readline() + + while notFoundStateEnd: + if string.find(line , "<event") > -1: + event = [] + event.append(line) + notFoundEventEnd = True + if string.find(line , "/>") > -1: + notFoundEventEnd = False + line = theFile.readline() + while notFoundEventEnd: + if string.find(line , "</event") > -1: + notFoundEventEnd = False + event.append(line) + line = theFile.readline() + stateInfo.append(event) + if string.find(line , "</midistate") > -1: + notFoundStateEnd = False + + # got all events + theFile.readline() # <audionode + # 0 1 2 3 4 + return ([clas,name,port,guiVisible,stateInfo]) + + def getAudio(self,theFile,currLine, atype, name, idx): + line = theFile.readline() # <channels> + ch = self.getSimpleValue(line) + + conn = "" + if atype == "audiomaster": # don't read any lines + pass + else: + line = theFile.readline() # <connect> + conn = self.getSimpleValue(line) + + line = theFile.readline() # <volume> + vol = self.getSimpleValue(line) + line = theFile.readline() # <pan> + pan = self.getSimpleValue(line) + + line = theFile.readline() # <mute> + mute = self.getSimpleValue(line) + line = theFile.readline() # <solo> + solo = self.getSimpleValue(line) + + line = theFile.readline() # <prefader> + pre = self.getSimpleValue(line) + + line = theFile.readline() # <off> + off = self.getSimpleValue(line) + + line = theFile.readline() # <plugin 1 + p1=[] + p2=[] + p3=[] + p4=[] + if string.find(line , "<plugin") > -1: + notFoundPlugEnd = True + while notFoundPlugEnd: + p1.append(line) + line = theFile.readline() # <plugin 1 + if string.find(line , "</plugin") > -1: + p1.append(line) + notFoundPlugEnd = False + + line = theFile.readline() # <plugin 2 + if string.find(line , "<plugin") > -1: + notFoundPlugEnd = True + while notFoundPlugEnd: + p2.append(line) + line = theFile.readline() # <plugin 2 + if string.find(line , "</plugin") > -1: + p2.append(line) + notFoundPlugEnd = False + + line = theFile.readline() # <plugin 3 + if string.find(line , "<plugin") > -1: + notFoundPlugEnd = True + while notFoundPlugEnd: + p3.append(line) + line = theFile.readline() # <plugin 3 + if string.find(line , "</plugin") > -1: + p3.append(line) + notFoundPlugEnd = False + + line = theFile.readline() # <plugin 4 + if string.find(line , "<plugin") > -1: + notFoundPlugEnd = True + while notFoundPlugEnd: + p4.append(line) + line = theFile.readline() # <plugin 4 + if string.find(line , "</plugin") > -1: + p3.append(line) + notFoundPlugEnd = False + + print "atype=", atype + print "p1=", p1 + print "p2=", p2 + print "p3=", p3 + print "p4=", p4 + + return([atype,name,idx,ch,conn,vol,pan,mute,solo,pre,off, p1,p2,p3,p4]) # add them together + + def checkAGroup(self, theFile, currLine): + if string.find(currLine , "<audiogroup") > -1: + print "AUDIOGROUP" + theFile.readline() # <audiogroup> + idx = self.getProperty(currLine, "idx") + print "idx=",idx + data = self.getAudio(theFile,currLine,"audiogroup", "Group %s"%(chr(int(idx)+65)),idx) + adata.append(data) + theFile.readline() # </audiogroup> + return True + else: + return False + + def checkSynth(self, theFile, currLine): + if string.find(currLine , "<synth") > -1: + print "SYNTH" + synt = self.getSynth(theFile,currLine) + data = self.getAudio(theFile,currLine,"synth", synt[1], 0) + print "got synth, name=%s route=%s",synt[1], data[5] + + theFile.readline() # </synth> + synths.append(synt) + adata.append(data) + + return True + else: + return False + + def checkAMaster(self, theFile, currLine): + if string.find(currLine , "<audiomaster") > -1: + print "AUDIOMASTER" + theFile.readline() # <audiomaster> + data = self.getAudio(theFile,currLine,"audiomaster", "Master",-1) + adata.append(data) + theFile.readline() # </audiomaster> + return True + else: + return False + + def checkAInput(self, theFile, currLine): + if string.find(currLine , "<audioinput") > -1: + print "AUDIOINPUT" + theFile.readline() # <audioinput> + idx = self.getProperty(currLine, "idx") + data = self.getAudio(theFile,currLine,"audioinput", "In 1",idx) + adata.append(data) + theFile.readline() # </audioinput> + return True + else: + return False + + # returns the property + def getProperty(self, currLine, tag): + prePtr = string.find(currLine , tag) + if prePtr == -1: + return -1 + firstPtr = string.find(currLine[prePtr:] , "\"") + lastPtr = string.find(currLine[firstPtr+prePtr+1:] , "\"") + return currLine[firstPtr+prePtr+1:firstPtr+prePtr+lastPtr+1] + + def checkMGroup(self, theFile, currLine): + if string.find(currLine , "<midiport") > -1: + print "MIDIPORT" + idx = self.getProperty(currLine, "idx") + line = theFile.readline() # <instrument> + inst = self.getSimpleValue(line) + line = theFile.readline() # <name> + name = self.getSimpleValue(line) + line = theFile.readline() # <record> + rec = self.getSimpleValue(line) + midiports.append([idx, inst, name,rec]) # add them together + line = theFile.readline() # </midiport> + return True + else: + return False + + + # retrieve the value of a simple XML tag + # format is important, must be: + # <tag>value</tag> + def getSimpleValue(self, line): + firstPtr = string.find(line, ">") # find end of first tag + lastPtr = string.find(line, "</") + outStr = line[firstPtr+1:lastPtr] + return outStr + + def checkClip(self, theFile, currLine): + if string.find(currLine , "<clip>") > -1: + if self.insidePart == False: + print "CLIP" + line = theFile.readline() # <file> + fil = self.getSimpleValue(line) + line = theFile.readline() # <name> + nam = self.getSimpleValue(line) + line = theFile.readline() # <name> + tick = self.getSimpleValue(line) + clips.append([nam, fil, tick]) # add them together + line = theFile.readline() # <len> + line = theFile.readline() # </clip> + else: + print "insertClip" + clipname = self.getSimpleValue(currLine) + for clip in clips: + if clip[0] == clipname: + outFile.write(" <frame>%s</frame>\n"%(clip[2])) + outFile.write(" <file>%s</file>\n"%(clip[1])) + return True + else: + return False + + + + def checkPart(self, theFile, currLine): + if string.find(currLine , "<part>") > -1: + print "PART" + self.insidePart = True + elif string.find(currLine , "</part>") > -1: + print "/PART" + self.insidePart = False + + def checkWaveTrack(self, theFile, currLine): + if string.find(currLine , "</wavetrack>") > -1: + print "/WAVETRACK" + self.insideWaveTrack = False + return False + elif string.find(currLine , "<wavetrack>") > -1: + print "WAVETRACK" + self.insideWaveTrack = True + return False + + if self.insideWaveTrack: # create dummy adata for the routing + if string.find(currLine , "<connect>") > -1: + con = self.getSimpleValue(currLine) + + #adata.append([atype,name,idx,ch,conn,vol,pan,mute,solo,pre,off, p1,p2,p3,p4]) + print ["wavetrack", self.currWaveTrackName,0,0,con,0,0,0,0,0,0,0,0,0,0] + adata.append(["wavetrack", self.currWaveTrackName,0,0,con,0,0,0,0,0,0,0,0,0,0]) + + return True + + elif string.find(currLine , "<audionode") > -1: + print "AUDIONODE - in wave track" + return True + elif string.find(currLine , "</audionode") > -1: + print "AUDIONODE - in wave track" + return True + elif string.find(currLine , "<volume>") > -1: + vol = self.getSimpleValue(currLine) + outFile.write(" <controller id=\"0\" cur=\"%s\">\n"%vol) + outFile.write(" </controller>\n") + return True + elif string.find(currLine , "<pan>") > -1: + pan = self.getSimpleValue(currLine) + outFile.write(" <controller id=\"1\" cur=\"%s\">\n"%pan) + outFile.write(" </controller>\n") + return True + return False + + def getWaveTrackName(self, theFile, currLine): + if self.insideWaveTrack and not self.insidePart: + if string.find(currLine , "<name>") > -1: + print "WAVETRACK - NAME" + self.currWaveTrackName = self.getSimpleValue(currLine) + print "self.currWaveTrackName =", self.currWaveTrackName + elif self.insideWaveTrack and self.insidePart: + pass + else: + self.currWaveTrackName = "" + + def checkTriggerForAdd(self, theFile, currLine): + if string.find(currLine , "<tempolist") > -1: + # we're in business, add ALL stored info: + # 1. AudioOutput + # 2. AudioInput + # 3. AudioGroup + # 4. SynthI + # 5. Routes + # + # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + # adata.append([atype,name,idx,ch,conn,vol,pan,mute,solo,pre,off,p1,p2,p3,p4]) + + # 1. + for line in adata: + if line[0] == "audiomaster": + #print "amaster" + #print line + outFile.write(" <AudioOutput>\n") + outFile.write(" <name>%s</name>\n"%line[1]) + outFile.write(" <record>0</record>\n") + outFile.write(" <mute>%s</mute>\n"%line[7]) + outFile.write(" <solo>%s</solo>\n"%line[8]) + outFile.write(" <off>%s</off>\n"%line[10]) + outFile.write(" <channels>%s</channels>\n"%line[3]) + outFile.write(" <height>20</height>\n") + outFile.write(" <locked>0</locked>\n") + outFile.write(" <prefader>%s</prefader>\n"%line[9]) + outFile.write(" <automation>1</automation>\n") + outFile.write(" <controller id=\"0\" cur=\"%s\">\n"%line[5]) + outFile.write(" </controller>\n") + outFile.write(" <controller id=\"1\" cur=\"%s\">\n"%line[6]) + outFile.write(" </controller>\n") + if line[11] !=[]: + print "%s line[11] %s"%(line[1],line[11]) + for pl in line[11]: + outFile.write(pl) + if line[12] !=[]: + print "%s line[12] %s"%(line[1],line[12]) + for pl in line[12]: + outFile.write(pl) + if line[13] !=[]: + print "%s line[13] %s"%(line[1],line[13]) + for pl in line[13]: + outFile.write(pl) + if line[14] !=[]: + print "%s line[14] %s"%(line[1],line[14]) + for pl in line[14]: + outFile.write(pl) + outFile.write(" </AudioOutput>\n") + + # 2. + for line in adata: + if line[0] == "audioinput": + outFile.write(" <AudioInput>\n") + outFile.write(" <name>%s</name>\n"%line[1]) + outFile.write(" <record>0</record>\n") + outFile.write(" <mute>%s</mute>\n"%line[7]) + outFile.write(" <solo>%s</solo>\n"%line[8]) + outFile.write(" <off>%s</off>\n"%line[10]) + outFile.write(" <channels>%s</channels>\n"%line[3]) + outFile.write(" <height>20</height>\n") + outFile.write(" <locked>0</locked>\n") + outFile.write(" <prefader>%s</prefader>\n"%line[9]) + outFile.write(" <automation>1</automation>\n") + outFile.write(" <controller id=\"0\" cur=\"%s\">\n"%line[5]) + outFile.write(" </controller>\n") + outFile.write(" <controller id=\"1\" cur=\"%s\">\n"%line[6]) + outFile.write(" </controller>\n") + if line[11] !=[]: + print "%s line[11] %s"%(line[1],line[11]) + for pl in line[11]: + outFile.write(pl) + if line[12] !=[]: + print "%s line[12] %s"%(line[1],line[12]) + for pl in line[12]: + outFile.write(pl) + if line[13] !=[]: + print "%s line[13] %s"%(line[1],line[13]) + for pl in line[13]: + outFile.write(pl) + if line[14] !=[]: + print "%s line[14] %s"%(line[1],line[14]) + for pl in line[14]: + outFile.write(pl) + outFile.write(" </AudioInput>\n") + + # 3. + for line in adata: + if line[0] == "audiogroup": + outFile.write(" <AudioGroup>\n") + outFile.write(" <name>%s</name>\n"%line[1]) + outFile.write(" <record>0</record>\n") + outFile.write(" <mute>%s</mute>\n"%line[7]) + outFile.write(" <solo>%s</solo>\n"%line[8]) + outFile.write(" <off>%s</off>\n"%line[10]) + outFile.write(" <channels>%s</channels>\n"%line[3]) + outFile.write(" <height>20</height>\n") + outFile.write(" <locked>0</locked>\n") + outFile.write(" <prefader>%s</prefader>\n"%line[9]) + outFile.write(" <automation>1</automation>\n") + outFile.write(" <controller id=\"0\" cur=\"%s\">\n"%line[5]) + outFile.write(" </controller>\n") + outFile.write(" <controller id=\"1\" cur=\"%s\">\n"%line[6]) + outFile.write(" </controller>\n") + if line[11] !=[]: + print "%s line[11] %s"%(line[1],line[11]) + for pl in line[11]: + outFile.write(pl) + if line[12] !=[]: + print "%s line[12] %s"%(line[1],line[12]) + for pl in line[12]: + outFile.write(pl) + if line[13] !=[]: + print "%s line[13] %s"%(line[1],line[13]) + for pl in line[13]: + outFile.write(pl) + if line[14] !=[]: + print "%s line[14] %s"%(line[1],line[14]) + for pl in line[14]: + outFile.write(pl) + outFile.write(" </AudioGroup>\n") + + # 4. + for line in adata: + if line[0] == "synth": + outFile.write(" <SynthI>\n") + outFile.write(" <name>%s</name>\n"%line[1]) + outFile.write(" <record>0</record>\n") + outFile.write(" <mute>%s</mute>\n"%line[7]) + outFile.write(" <solo>%s</solo>\n"%line[8]) + outFile.write(" <off>%s</off>\n"%line[10]) + outFile.write(" <channels>%s</channels>\n"%line[3]) + outFile.write(" <height>20</height>\n") + outFile.write(" <locked>0</locked>\n") + outFile.write(" <prefader>%s</prefader>\n"%line[9]) + outFile.write(" <automation>1</automation>\n") + outFile.write(" <controller id=\"0\" cur=\"%s\">\n"%line[5]) + outFile.write(" </controller>\n") + outFile.write(" <controller id=\"1\" cur=\"%s\">\n"%line[6]) + outFile.write(" </controller>\n") + +# event data + for synt in synths: + if synt[1] == line[1]: + # we found this synth, proceed + outFile.write(" <class>%s</class>\n"%synt[0]) + outFile.write(" <port>%s</port>\n"%synt[2]) + outFile.write(" <guiVisible>%s</guiVisible>\n"%synt[3]) + outFile.write(" <midistate>\n") + + if synt[0] == "fluidsynth": + # Woaaahh, special treatment, do I have something for you!!!! + self.processFluid(synt) + else: + # Other synth + for state in synt[4]: + for evl in state: + outFile.write(evl) + + outFile.write(" </midistate>\n") + + + + #return ([clas,name,port,guiVisible,stateInfo]) + + outFile.write(" </SynthI>\n") + + # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + # adata.append([atype,name,idx,ch,conn,vol,pan,mute,solo,pre,off,p1,p2,p3,p4]) + + # 5. - create all routes + for line in adata: + for line2 in adata: + if line[4] == line2[1]: + print ">route %s line[4]=%s %s line2[1]=%s"%(line[1],line[4],line2[1],line2[1]) + outFile.write(" <Route>\n") + outFile.write(" <srcNode>%s</srcNode>\n"%line[1]) + outFile.write(" <dstNode>%s</dstNode>\n"%line2[1]) + outFile.write(" </Route>\n") + else: + print "-route %s line[4]=%s %s line2[1]=%s"%(line[1],line[4],line2[1],line2[1]) + + outFile.write(" <Route>\n") + outFile.write(" <srcNode>1:Master</srcNode>\n") + outFile.write(" <dstNode>alsa_pcm:playback_1</dstNode>\n") + outFile.write(" </Route>\n") + outFile.write(" <Route>\n") + outFile.write(" <srcNode>2:Master</srcNode>\n") + outFile.write(" <dstNode>alsa_pcm:playback_2</dstNode>\n") + outFile.write(" </Route>\n") + + def processFluid(self, fluid): + # here we go + print "Fluidsynth!!" + #for state in fluid[4]: + # for evl in state: + # outFile.write(evl) + + # ok, let's convert the first event + + outdata=" " + nbrOfFonts=0 + counter2f = 0 + externalConnects=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + externalConnects2f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] + for event in fluid[4]: + hexstr = self.convertEventToHexStr(event) + print hexstr + counter1 = 0 + counter2 = 0 + if hexstr[0] == "28": + externalConnects[nbrOfFonts] = hexstr[1] + nbrOfFonts = nbrOfFonts+1 + for h in hexstr[2:-1]: + outdata = outdata + "%s "%h + counter1 == counter1 + 1 + counter2 == counter2 + 1 + if counter1 > 9: + outdata = outdata + "\n " + counter1= 0 + + elif hexstr[0] == "2f": + # ext_id preset channel + externalConnects2f[counter2f] = "%s %s %s "%(hexstr[1],hexstr[3], "00") #hexstr[2]) + counter2f=counter2f+1 + # translate + # initStr = "f2 00 03 01 2f 00" # fluid v3 , one soundfont, lastdir= "/" + + + + outFile.write(" <event type=\"2\" datalen=\"2000\">\n") #%(len(hex)-3)) + outFile.write(" f2 00 03 0%X 2f 00\n"%nbrOfFonts) + outFile.write(outdata) + outFile.write("\n ff ") + for i in range(nbrOfFonts): + outFile.write("%s "%(externalConnects[i])) + outFile.write("\n ") + for ext in externalConnects2f: + outFile.write(ext) + outFile.write("\n 00 00 00 00 00 00 00 00\n") + outFile.write(" 00 00 00 00 ff ff ff ff 00 00 00 00 00 00\n") + + #outFile.write(" ff 00 00 81 00 7f 81 00 7f\n") +# outFile.write(" 81 00 7f 81 00 7f 81 00 7f 81 00 7f 81 00 7f 81\n") +# outFile.write(" 00 7f 81 00 7f 81 00 7f 81 00 7f 81 00 7f 81 00\n") +# outFile.write(" 7f 81 00 7f 81 00 7f 81 00 00 00 00 00 00 00 00\n") + outFile.write(" </event>\n") + + + + def convertEventToHexStr(self, event): + # here we go + newLine=[] + for line in event[1:-1]: + splitLine = string.split(line) + nbr = len(splitLine) + #print nbr + #print splitLine + + count = 0 + while count < nbr: + newLine.append("%s%s"%(splitLine[count][1],splitLine[count+1][1])) + count = count + 2 + + #print newLine + + return newLine + + + + +def help(): + print "Utility to convert MusE 0.6 songs to 0.7 or newer song format." + print "Usage: muse-convert <song file to convert>" + print "" + print "Please report any problems with this script to rj@spamatica.se" + print "Author: Robert Jonsson, 2005, Copylefted under the GPL" + +######################## +# --- Main program --- # +######################## + +print "MusE Song converter %s"%version +print "" + +if len(sys.argv) < 2: + help() + sys.exit("") + +print "Processing file ", sys.argv[1] +print "" +# step 1 - remove malformed data +inFile = file(sys.argv[1]) + +outFile = file(sys.argv[1]+".tmp","w") +fileEnd = False + +convert = MusEConvert() + +#take care of first few lines: +outFile.write(inFile.readline()) # <?xml +line = inFile.readline() # <muse string +if string.find(line, "<muse version=\"1.0\">") == -1: + print "Unable to confirm that this is a song file with the old format, aborting..." + sys.exit("") +outFile.write("<muse version=\"2.0\" comment=\"converted by muse converter v%s\">\n"%version) + + +while fileEnd == False: + line = inFile.readline() + if line == "": + fileEnd = True + newLine = convert.fixComma(inFile,line) + outFile.write(newLine) + +inFile.close() +outFile.close() + +#sys.exit("") +inFile = file(sys.argv[1]+".tmp","r") +outFile = file(sys.argv[1]+".converted","w") +fileEnd = False + +while fileEnd == False: + line = inFile.readline() + if line == "": + fileEnd = True + + convert.checkPart(inFile,line) # only state variables + convert.getWaveTrackName(inFile,line) # only state variables + + convert.checkTriggerForAdd(inFile,line) # insert routes+stuff? + + if convert.findAndSkipBlock(inFile, line) == True: + pass + elif convert.checkAGroup(inFile,line): + pass + elif convert.checkAMaster(inFile,line): + pass + elif convert.checkSynth(inFile,line): + pass + elif convert.checkAInput(inFile,line): + pass + #elif convert.checkMGroup(inFile,line): + # pass + elif convert.checkClip(inFile,line): + pass + elif convert.checkWaveTrack(inFile,line): # only state variables + pass + else: + outFile.write(line) + +print "" +print "Converted!" +print "" |