~ubuntu-branches/ubuntu/saucy/muse/saucy

« back to all changes in this revision

Viewing changes to share/scripts/Rhythm1

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2013-01-07 10:27:14 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20130107102714-fajkwjbz02aqupbh
Tags: 2.1-1
* New upstream release.
* Refresh 1001-buildsystem.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
# MusE external midi processing script
 
4
# By: Robert Jonsson 2012
 
5
# Rhythm1
 
6
#=============================================================================
 
7
#  MusE
 
8
#  Linux Music Editor
 
9
#  $Id:$
 
10
#
 
11
#  Copyright (C) 2002-2011 by Werner Schweer and others
 
12
#
 
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.
 
17
#
 
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.
 
22
#
 
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
#=============================================================================
 
28
 
 
29
import sys,time
 
30
testFile = file(sys.argv[1],"r")
 
31
inputEvents = testFile.readlines()
 
32
testFile.close()
 
33
 
 
34
outputEvents=[]
 
35
BAR=0
 
36
BEAT=0
 
37
BEATLEN=0
 
38
QUANTLEN=0
 
39
PARTLEN=0
 
40
 
 
41
hihatNote="42"
 
42
kickNote="35"
 
43
snareNote="38"
 
44
length="1"
 
45
velocity="100"
 
46
 
 
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(' ')
 
52
    BAR = int(bar)
 
53
    BEAT = int(beat)
 
54
  if line.startswith('BEATLEN'):
 
55
    tag,beatLen = line.split(' ')
 
56
    BEATLEN=int(beatLen)
 
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)
 
63
    
 
64
######################################
 
65
######################################
 
66
 
 
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)
 
71
  
 
72
  if ticking % (BEATLEN * 4) - (BEATLEN * 2) == 0:
 
73
    newline = "NOTE " + str(ticking) + " " + snareNote + " " + length + " " + velocity + "\n"
 
74
    outputEvents.append(newline)
 
75
 
 
76
  if ticking % (BEATLEN) == 0:
 
77
    newline = "NOTE " + str(ticking) + " " + hihatNote + " " + length + " " + velocity + "\n"
 
78
    outputEvents.append(newline)
 
79
 
 
80
testFile = file(sys.argv[1],"w")
 
81
testFile.writelines(outputEvents)
 
82
testFile.close()
 
83
 
 
84
#testFile2 = file("/home/ddskrjo/o2.txt","w")
 
85
#testFile2.writelines(outputEvents)
 
86
#testFile2.close()