2
# -*- coding: utf-8 -*-
3
# MusE external midi processing script
4
# By: Robert Jonsson 2012
6
#=============================================================================
11
# Copyright (C) 2002-2011 by Werner Schweer and others
13
# This program is free software; you can redistribute it and/or modify
14
# it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the
25
# Free Software Foundation, Inc.,
26
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27
#=============================================================================
30
testFile = file(sys.argv[1],"r")
31
inputEvents = testFile.readlines()
47
#loop through events reading configuration
48
for line in inputEvents:
49
outputEvents.append(line)
50
if line.startswith('TIMESIG'):
51
tag,bar,beat = line.split(' ')
54
if line.startswith('BEATLEN'):
55
tag,beatLen = line.split(' ')
57
if line.startswith('QUANTLEN'):
58
tag,quantLen = line.split(' ')
59
QUANTLEN = int(quantLen)
60
if line.startswith('PART'):
61
tag,start,end = line.split(' ')
62
PARTLEN = int(end) - int(start)
64
######################################
65
######################################
67
for ticking in range(0,PARTLEN):
68
if ticking % (BEATLEN * 4) == 0:
69
newline = "NOTE " + str(ticking) + " " + kickNote + " " + length + " " + velocity + "\n"
70
outputEvents.append(newline)
72
if ticking % (BEATLEN * 4) - (BEATLEN * 2) == 0:
73
newline = "NOTE " + str(ticking) + " " + snareNote + " " + length + " " + velocity + "\n"
74
outputEvents.append(newline)
76
if ticking % (BEATLEN) == 0:
77
newline = "NOTE " + str(ticking) + " " + hihatNote + " " + length + " " + velocity + "\n"
78
outputEvents.append(newline)
80
testFile = file(sys.argv[1],"w")
81
testFile.writelines(outputEvents)
84
#testFile2 = file("/home/ddskrjo/o2.txt","w")
85
#testFile2.writelines(outputEvents)