| Trees | Indices | Help |
|
|---|
|
|
1 """Shell tools relating to input data types. 2 3 """ 4 """ 5 ============================== License ======================================== 6 Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 7 8 This file is part of The Jazz Parser. 9 10 The Jazz Parser is free software: you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation, either version 3 of the License, or 13 (at your option) any later version. 14 15 The Jazz Parser is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with The Jazz Parser. If not, see <http://www.gnu.org/licenses/>. 22 23 ============================ End license ====================================== 24 25 """ 26 __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>" 27 28 from jazzparser.shell.tools import Tool 29 from jazzparser.shell import ShellError32 name = "Input lister" 33 commands = ["input"] 34 usage = ("input", "show the input data object") 35 help = """\ 36 Very simple tool to display the input data. It doesn't do anything fancy to 37 output the contents of the data, but just prints out the data object's 38 str. 39 """ 404346 name = "Midi chunk player" 47 commands = ["play"] 48 usage = ("play", "play the MIDI input chunk by chunk") 49 help = """\ 50 Input tool specially for segmented MIDI input. Will play the input chunk by 51 chunk. Use a keyboard interrupt (Ctrl+C) to stop playback. 52 """ 538155 from jazzparser.data.input import SegmentedMidiInput 56 if state.input_data is None or type(state.input_data) != SegmentedMidiInput: 57 raise ShellError, "input is not playable" 58 59 if len(args) > 0: 60 chunk = int(args[0]) 61 else: 62 chunk = None 63 64 PlayMidiChunksTool.play_segmidi(state.input_data, chunk=chunk)65 66 @staticmethod68 from jazzparser.utils.midi import play_stream 69 # Select an individual chunk if a number is given 70 if chunk is None: 71 strms = enumerate(segmidi) 72 else: 73 strms = [(chunk, segmidi[chunk])] 74 75 try: 76 for i,strm in strms: 77 print "Playing chunk %d (%d events)" % (i, len(strm.trackpool)) 78 play_stream(strm, block=True) 79 except KeyboardInterrupt: 80 print "Stopping playback"83 name = "Midi chunk player (bulk)" 84 commands = ["play"] 85 usage = ("play [<input number> [<chunk number>]]", "play the numbered MIDI input (the first by default)") 86 help = """\ 87 Input tool specially for segmented MIDI input, bulk input version. 88 89 Will play the input chunk by chunk. Use a keyboard interrupt (Ctrl+C) to stop 90 playback. 91 """ 92115 13594 from jazzparser.data.input import SegmentedMidiBulkInput 95 96 if len(args) == 0: 97 inputno = 0 98 else: 99 try: 100 inputno = int(args[0]) 101 except ValueError: 102 raise ShellError, "input number must be an integer" 103 104 # Check we have appropriate input 105 if state.input_data is None or type(state.input_data) != SegmentedMidiBulkInput: 106 raise ShellError, "input is not playable" 107 108 if len(args) == 2: 109 chunk = int(args[1]) 110 else: 111 chunk = None 112 113 segmidi = state.input_data[inputno] 114 PlayMidiChunksTool.play_segmidi(segmidi, chunk=chunk)
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 26 16:05:00 2012 | http://epydoc.sourceforge.net |