• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python midi.read_midifile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中midi.read_midifile函数的典型用法代码示例。如果您正苦于以下问题:Python read_midifile函数的具体用法?Python read_midifile怎么用?Python read_midifile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_midifile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testIsEmptyTrack

def testIsEmptyTrack():
    pat1 = midi.read_midifile('tests/trk15empty.mid')
    assert(isEmptyTrack(15,pat1) == True)
    pat2 =  midi.read_midifile('tests/empty.mid')
    assert(isEmptyTrack(0,pat2) == True)
    pat3 = midi.read_midifile('tests/notEmpty.mid')
    assert(isEmptyTrack(1,pat3)== False)
开发者ID:ajayk111,项目名称:MIDorI,代码行数:7,代码来源:MIDorI.py


示例2: id_pattern_itter

def id_pattern_itter(db):
    for record in db["records"]:
        record = db["records"][record]
        yield (record["id"], midi.read_midifile(StringIO.StringIO(record["data"])))
        for bar in record["bars"]:
            yield(bar["id"],midi.read_midifile(StringIO.StringIO(bar["data"])))
        for track in record["bars"]:
            yield(track["id"],midi.read_midifile(StringIO.StringIO(track["data"])))
        for bar_track in record["bars_tracks"]:
            yield(bar_track["id"],midi.read_midifile(StringIO.StringIO(bar_track["data"])))
开发者ID:EQ4,项目名称:b0rkestra,代码行数:10,代码来源:mididb.py


示例3: test_mary

 def test_mary(self): 
     midi.write_midifile("mary.mid", mary_test.MARY_MIDI)
     pattern1 = midi.read_midifile("mary.mid")
     midi.write_midifile("mary.mid", pattern1)
     pattern2 = midi.read_midifile("mary.mid")
     self.assertEqual(len(pattern1), len(pattern2))
     for track_idx in range(len(pattern1)):
         self.assertEqual(len(pattern1[track_idx]), len(pattern2[track_idx]))
         for event_idx in range(len(pattern1[track_idx])):
             event1 = pattern1[track_idx][event_idx]
             event2 = pattern1[track_idx][event_idx]
             self.assertEqual(event1.tick, event2.tick)
             self.assertEqual(event1.data, event2.data)
开发者ID:LeChuck42,项目名称:python-midi,代码行数:13,代码来源:tests.py


示例4: main

def main():
    #pattern1 = midi.read_midifile("midi/5RAP_04.MID")
    bars = []
    pattern = midi.read_midifile("midi/5RAP_04.MID")
    #pattern = midi.read_midifile("midi/decoy.mid")
    #pattern = midi.read_midifile("midi/drum_patterns.mid")

    #print_events(pattern, [])
    pattern = sanitize(pattern)

    midi.write_midifile("test.mid", pattern)
    pattern = midi.read_midifile("test.mid")
    print pattern
    return
开发者ID:EQ4,项目名称:b0rkestra,代码行数:14,代码来源:midisanitize.py


示例5: main

def main():
    usage = "%prog <seq-id> <midi-file> [<midi-file> ...]"
    parser = OptionParser(usage=usage)
    parser.add_option("--names", dest="names", action="store", help="read in a NAMES file from the midi auto-collection, intead of reading midi files from the command line")
    options, arguments = parser.parse_args()
    
    if options.names is not None:
        print "Reading names from %s" % options.names
        csv = UnicodeCsvReader(open(options.names))
        filenames = []
        dirname = os.path.dirname(options.names)
        
        csv.next()
        for row in csv:
            filename = os.path.join(dirname,row[0])
            if not os.path.exists(filename):
                continue
            seq = ChordSequence.objects.get(id=int(row[2]))
            filenames.append((seq,filename))
    else:
        if len(arguments) < 2:
            print >>sys.stderr, "Specify a sequence id and one or more midi files"
            sys.exit(1)
        
        seq_id = int(arguments[0])
        seq = ChordSequence.objects.get(id=seq_id)
        filenames = [(seq,fn) for fn in arguments[1:]]
        
    if len(filename) == 0:
        print sys.stderr, "No input files"
        sys.exit()
    
    files = []
    for seq,filename in filenames:
        print "Reading %s" % filename
        f = open(filename, 'r')
        data = f.read()
        # Try reading in the midi data to check it's ok
        read_midifile(StringIO(data))
        files.append((seq, os.path.basename(filename), ContentFile(data)))
    
    for seq, filename,f in files:
        print "Storing %s" % filename
        # Create a new midi data record in the database
        midi = MidiData()
        midi.sequence = seq
        midi.save()
        # Use the original filename
        midi.midi_file.save(filename, f)
        midi.save()
开发者ID:johndpope,项目名称:jazzparser,代码行数:50,代码来源:add_midi.py


示例6: openOptions

def openOptions(): #Options window UI
    top=Toplevel()
    Label(top, text="Chain Length: ").grid(row=0)
    Label(top, text="Instrument: ").grid(row=1)
    Label(top, text="Song Length: ").grid(row=2)
    Label(top, text="Tempo: ").grid(row=3)
    Label(top, text="Input Track: ").grid(row=4)
    lengths=range(2,10) #possible chain lengths
    c.d.chainLengthPicker=apply(OptionMenu,(top,c.d.chainLength)+tuple(lengths))
    c.d.chainLengthPicker.grid(row=0,column=1)
    instruments=c.d.instruments.keys()
    c.d.instrumentPicker=OptionMenu(top,c.d.instrumentName,*instruments,\
    command=setInstrument)
    c.d.instrumentPicker.grid(row=1,column=1)
    c.d.songLengthPicker=Entry(top,textvariable=c.d.songLength,\
    validatecommand=validateLength)
    c.d.songLengthPicker.grid(row=2,column=1)
    c.d.tempoPicker=Entry(top,textvariable=c.d.tempo,\
    validatecommand=validateTempo)
    c.d.tempoPicker.grid(row=3,column=1)
    tracks=[1] #default track
    if(c.d.inputFile.get() !=''):
        pat=midi.read_midifile(c.d.inputFile.get())
        tracks=range(len(pat))
    c.d.trackPicker=apply(OptionMenu,(top,c.d.track)+tuple(tracks))
    c.d.trackPicker.grid(row=4,column=1)
开发者ID:ajayk111,项目名称:MIDorI,代码行数:26,代码来源:MIDorI.py


示例7: load

 def load(self, filename):
     '''Load MIDI file'''
     pattern = midi.read_midifile(filename)        
     self.resolution = pattern.resolution
     pattern.make_ticks_abs()
     events = []
     for track in pattern:
         for event in track:
             events.append(event)
     events.sort()
     cues = []
     for e in events:
         if type(e) == midi.events.TextMetaEvent:
             if e.text.startswith('cue'):
                 cues.append(e.tick)
     self.cues = cues
     self.events = events
     self.eventnum = 0
     self.tempo = 120.0
     self.time = 0
     self._playing = False
     self.softReset()
     while self.eventnum < len(self.events) and self.events[self.eventnum].tick < 2:
             event = self.events[self.eventnum]
             self.eventnum += 1
             self.do_event(event)
开发者ID:nwhitehead,项目名称:cuemidi,代码行数:26,代码来源:cuemidi.py


示例8: time_series_list_builder

def time_series_list_builder(filename_io_mid):
	'''
	INPUT: STR : The name of MIDI file 'bwv733_io.mid' extracted out of Ableton into typically 3 separate
	 			MIDI files 'bwv733_t1.mid', 'bwv733_t2.mid', 'bwv733_t3.mid' 
				and merged with merger_t1s('bwv733.mid') 
	
	OUTPUT: time_series LIST [(time INT, pitch INT, duration INT), ...]: time-sorted
	
	
	'''
	tracks = midi.read_midifile(filename_io_mid)
	
	note_on = [0 for i in tracks]
	note_off = [0 for i in tracks]
	time_series_list = []
	
	for i, track in enumerate(tracks):
		note_on[i], note_off[i] = extract_melody(track)
		if len(note_on[i]) != len(note_off[i]):
			print '''len(note_on)={} and len(note_off)={} @track={}'''\
			.format(len(note_on[i]), len(note_off[i]), i)
		
		out = time_series_builder(note_on[i], note_off[i])
		if len (out) > 0:
			time_series_list.append(out)
	
	return time_series_list
开发者ID:ozkansafak,项目名称:Galvanize-Capstone-Project,代码行数:27,代码来源:preprocess_0.py


示例9: to_int_array

def to_int_array(file_location):
    pattern = midi.read_midifile(file_location)

    return [
        event.data[0] for track in pattern for event in track
        if isinstance(event, midi.NoteOnEvent) and event.data[1] > 0
    ]
开发者ID:jefk,项目名称:synthetic-music,代码行数:7,代码来源:read_midi.py


示例10: notes_from_file

def notes_from_file(filename: str) -> List[Note]:
    midifile_rel = midi.read_midifile(filename)
    midifile_abs = copy.deepcopy(midifile_rel)
    midifile_abs.make_ticks_abs()

    # Convert MIDI events to our music representation: a list of Note objects
    notes = []
    active_notes = {}

    for ev_rel, ev_abs in zip(midifile_rel[-1], midifile_abs[-1]):
        if isinstance(ev_rel, midi.NoteOnEvent) and ev_rel.data[1]:
            n = Note()
            n.resolution = midifile_rel.resolution
            n.tick_abs = ev_abs.tick
            n.pitch = ev_rel.data[0]
            n.velocity = ev_rel.data[1]
            if n.pitch not in active_notes:
                active_notes[n.pitch] = {n}
            else:
                active_notes[n.pitch].add(n)
        elif isinstance(ev_rel, midi.NoteOffEvent) or (isinstance(ev_rel, midi.NoteOnEvent) and ev_rel.data[1] == 0):
            n = active_notes[ev_rel.data[0]].pop()
            n.duration = ev_abs.tick - n.tick_abs
            notes.append(n)
    assert not any(active_notes.values()), "Some notes were not released"
    return sorted(notes, key=lambda note: note.tick_abs)
开发者ID:marczellm,项目名称:algorimp,代码行数:26,代码来源:file_handlers.py


示例11: Main

def Main():
	#these values should match what is in SongData
	#and are here just for reference
	#REST = 128
	#HOLD = 129
	#NULL = 130
	#END = 131
	#BEATS_PER_BAR = 32
	#extract features
	absolute_pos = 0
	folder = os.path.join('downloads','midiworld')
	pitches = set()
	songs = []
	observedstates = set()
	featurevectors = []	
	import csv	
	with open('features.csv','wb') as out:
		try:
			print('finding valid songs')
			csv_out=csv.writer(out)
			valid_filenames = []		
			for filename in os.listdir(folder):
				out_of_range = False
				song_path = os.path.join(folder, filename)
				pattern = midi.read_midifile(song_path)
				song = SongData(pattern, filename)
				for action in song.eventset:
					if (action > 84 and action < 128) or action < 48:
						out_of_range = True
					if song.startstate.pitch == 131:
						out_of_range = True
				if not out_of_range:
					valid_filenames.append(song.filename)
			print(len(valid_filenames))
			pdump(valid_filenames, 'valid_filenames.pkl',noPrefix=True)
开发者ID:wframe,项目名称:Capstone,代码行数:35,代码来源:LargeDataset.py


示例12: testcreateTune

	def testcreateTune(self):
		# --- tests if MIDI files are successfully converted to a Tune object ---
		# import midi file: C major scale with all quarter notes (refer to TestComputePitches)
		# Use Python MIDI library https://github.com/vishnubob/python-midi
		# MIDI files are an array of integers with a header
		TuneMIDI = midi.read_midifile("../tests/MIDITestFiles/c-major-scale-treble.mid")
		# ---- Fail Tune Parameter Constraints ---
		self.assertFalse(Tune("wrongFileType.txt"), Clef.TREBLE, "", [""])
		#  timeSignature has to be (int, int) where int > 0
		self.assertFalse(Tune(TuneMIDI), (-1, 0), Clef.BASS, "Title", ["Contributor"])
		self.assertFalse(Tune(TuneMIDI, (2.5, 3), Clef.BASS, "Title", ["Contributor"]))
		tune = Tune(TuneMIDI, (3,4), Clef.TREBLE, "Title", ["Contributor"])
		# --- test Tune setters and getters ---
		# If bad input, leave field unchanged
		tune.setTimeSignature((4,4))
		self.assertEqual(tune.getTimeSignature(), (4,4))
		tune.setTimeSignature((-1, 0))
		self.assertEqual(tune.getTimeSignature(), (4,4))
		tune.setTitle("new title")
		self.assertEqual(tune.getTitle(), "new title")
		tune.setTitle("this is toooooooooooooooooooooooooooooooooooooooooooo long title")
		self.assertEqual(tune.getTitle(), "new title")
		tune.setContributors(["person1, person2, person3"])
		self.assertEqual(tune.getContributors(), ["person1, person2, person3"])
		tune.setContributors(["this is tooooooooooooooooooooooooooooooooo long contributor name"])
		self.assertEqual(tune.getContributors(), ["person1, person2, person3"])

		frequencies = [261.63, 293.66, 329.63]
		# check frequencies and onsets calculated correctly from generateTune
		for i in xrange(0, 3):
			self.assertEqual(tune[i].getFrequency(), frequencies[i])
			self.assertEqual(tune[i].getOnset(), i)
			self.assertTrue(samerest.noteEqual(samerestNote))
开发者ID:rpinsker,项目名称:impromptu,代码行数:33,代码来源:backendtests2zoe.py


示例13: load_midi_file

    def load_midi_file(self, file_location):
        midi_file = midi.read_midifile(file_location)
        midi_file.reverse()
        midi_file.make_ticks_abs()

        resolution = midi_file.resolution
        song_info_track = midi_file.pop()

        has_tempo_event = False
        mpqn = 0  # milliseconds per quarter note

        for event in song_info_track:

            if type(event) is midi.SetTempoEvent:
                has_tempo_event = True
                mpqn = (event.data[0] << 16) | (event.data[1] << 8) | event.data[2]
                #  print "mpqn is&: ", mpqn

        if mpqn == 0:
            mpqn = 1
        current_tempo_in_beats_per_minute = 120

        if has_tempo_event:
            current_tempo_in_beats_per_minute = 60000000.0/mpqn

        self.bpm = current_tempo_in_beats_per_minute

        self.ms_per_tick = resolution * (current_tempo_in_beats_per_minute / 60.0)
        self.ms_per_tick = 1000.0/self.ms_per_tick
        self.song_buffer = SongBuffer(time_per_tick=self.ms_per_tick)
        # print self.ms_per_tick

        for track in midi_file:
            self.song_buffer.add_track(track)
开发者ID:SIGMusic,项目名称:LeapMusic,代码行数:34,代码来源:Main.py


示例14: get_tracknames

def get_tracknames():
    filenames = []
    count = 0
    for root, subFolders, files in os.walk('.'):
        count +=1
        if count == 9:
            break
        files = [os.path.join(root, filename) for filename in files if filename.lower().endswith(".mid")]
        filenames += files

    filenames = filenames[:100]
    tracknames = []
    for filename in filenames:
        print "processing", filename
        try:
            pattern = midi.read_midifile(filename)
            current_tracknames = midiutil.get_track_names(pattern)
            current_tracknames =  [trackname.rstrip().lstrip().lower().encode('ascii', 'ignore') for trackname in current_tracknames]
            #current_tracknames = [trackname for trackname in tracknames if trackname != ""]
            tracknames += current_tracknames 
        except:
            print "    bad file", filename
    tracknames = [' '.join(ch for ch in t if ch.isalnum()) for t in tracknames if t != '']
    print tracknames
    return tracknames
开发者ID:b0rkestra,项目名称:b0rkestra,代码行数:25,代码来源:midimetadata.py


示例15: get_notes

def get_notes():
    # downloaded from http://www.piano-midi.de/muss.htm
    filename = 'muss_1.mid'
    m = midi.read_midifile(filename)
    m.make_ticks_abs()
    tick = 120.0
    notes = np.array([(n.pitch, int(round(n.tick / tick)))
                      for n in m[1]
                      if type(n) == midi.events.NoteOnEvent
                      and n.velocity > 0
                      and n.pitch > 0])

    note_map = collections.defaultdict(list)
    max_pitch = 0
    min_pitch = 127
    for pitch, t in notes:
        note_map[t].append(pitch)
        if pitch > max_pitch:
            max_pitch = pitch
        elif pitch < min_pitch:
            min_pitch = pitch

    max_time = max(note_map.keys())

    output_units = max_pitch - min_pitch + 1
    output = np.zeros((max_time, output_units))
    for t in range(max_time):
        if t in note_map:
            for i in note_map[t]:
                output[t, i - min_pitch] = 1

    return output, min_pitch
开发者ID:andreasjansson,项目名称:piction-exhictures-at-an-exhibit-an-exhibition,代码行数:32,代码来源:genmus.py


示例16: parseMidiFile

	def parseMidiFile(self, filename):
		#self.output = [] #numpy.zeros(5)
		pattern = midi.read_midifile(filename)
		self.ppq = pattern.resolution
		for track in pattern:
			#print track
			self.tracks.append([]) #add a new empty track
			for event in track:
				#print repr(event)

				if type(event) is midi.events.SetTempoEvent:
					self.bpm = event.get_bpm() #change tempo

				if type(event) is midi.events.NoteOnEvent:
					self.generateAudio(event.tick, event.channel)
					note = event.pitch
					self.noteActive[note] = True
				elif type(event) is midi.events.NoteOffEvent:
					self.generateAudio(event.tick, event.channel)
					note = event.pitch
					self.noteActive[note] = False
		self.tracks.pop() #removes the extra added track (the first track is just metadata)

		track_len = min([len(track) for track in self.tracks])
		self.tracks = [track[0:track_len] for track in self.tracks] #trim all tracks to the exact same size
		self.output[0] = numpy.sum(self.tracks, axis=0) #combine tracks
		return self.output
开发者ID:tediris,项目名称:MusicML,代码行数:27,代码来源:sequencer.py


示例17: parseMidi

def parseMidi(filename):
	#Reads midi events from file
	stream = midi.read_midifile(filename)

	songName=""
	trackName=""
	tempo=75
	#Get info for track 0 (Song name and master tempo)
	for event in stream.get_track_by_number(0):
		if (event.name=="Track Name"):
			songName=event.data
			tempo=stream.get_tempo().tempo
			print "Song Name: "+songName+", tempo: "+str(tempo)

	#Get info for other tracks
	tracklist=sorted(stream.tracknames.items(), key=lambda trk: trk[1])

	num=0
	if not(len(tracklist)==0):
		#If there are more than one track in the file, you have to choose one
		for track in tracklist:
			if not(track[1]==0): print str(track[1])+") "+track[0]

		#Select a track to analize
		ok=0
		while not(ok):
			select=raw_input("Please insert track number you want to analyze [1.."+str(tracklist[-1][1])+"]: ")
			try:
				num=int(select)
				if (num>=1 and num<=tracklist[-1][1]):
					ok=1
				else:
					print "Number out of range"
			except ValueError:
				print "Invalid input"

	try:
		trackName=tracklist[num][0]
	except IndexError:
		print "Failed to get track name"

	if (songName==""): songName=filename.name.split(".")[0]
	if (trackName==""): trackName=songName

	print "scanning track "+trackName+"..."
	noteList=[]
	for event in stream.get_track_by_number(num):
		if (event.name=="Note On"):
			noteList.append(event)
			if (VERBOSE):
				print event
		if (event.name=="Note Off"):
			#Convert note off event in note on with velocity=0
			event.name="Note On"
			event.velocity=0
			noteList.append(event)
			if (VERBOSE):
				print event

	return (noteList, songName, trackName, tempo)
开发者ID:adegani,项目名称:Markovex,代码行数:60,代码来源:markov_analysis.py


示例18: read_midi_file

def read_midi_file(midi_path, channel=9, quantisation_level=1/16):
    midi_file = midi.read_midifile(midi_path)

    # Find the drum tracks
    drum_tracks = set()
    for index, track in midi_file.tracklist.iteritems():
        for event in track:
            if isinstance(event, midi.NoteEvent) and event.channel == 9:
                drum_tracks.add(index)
                break

    # tick beat^-1 = (tick quart^-1 * quart note^-1) / note beat^-1
    tpb = 4 * midi_file.resolution *  quantisation_level
    beats = {}
    for track_index in drum_tracks:
        midi_track = midi_file.tracklist[track_index]
        for event in midi_track:
            if isinstance(event, midi.NoteOnEvent) and event.channel == channel:
                beat_index = int(round(event.tick / tpb))
                if beat_index not in beats:
                    beats[beat_index] = set()
                beats[beat_index].add(event.pitch)
    if beats:
        track = [frozenset() for _ in xrange(max(beats) + 1)]
        for beat_index, beat in beats.iteritems():
            track[beat_index] = frozenset(beat)
    return tuple(track)
开发者ID:Man-UP,项目名称:monkey-drummer,代码行数:27,代码来源:io.py


示例19: main

def main():
    usage = "%prog [options] <in-file>"
    description = "Print out stats about the notes in a MIDI file"
    parser = OptionParser(usage=usage, description=description)
    parser.add_option('-k', '--key-profile', dest="key_profile", action="store", type="int", help="output a graph of the key profile for the given key as a gnuplot script")
    options, arguments = parse_args_with_config(parser)
    
    if len(arguments) == 0:
        print "No input MIDI file given"
        sys.exit(1)
    filename = arguments[0]
    
    # Load the midi file
    midi = read_midifile(filename)
    print "Midi file type %d" % midi.format
    print "Resolution: %d" % midi.resolution
    print "%d notes" % len(note_ons(midi))
    # Get rid of drums
    midi = simplify(midi, remove_drums=True)
    notes = note_ons(midi)
    print "%d non-drum notes" % len(notes)
    # Analyse the note content
    pcs = dict([(i,0) for i in range(12)])
    for note in notes:
        pcs[note.pitch % 12] += 1
    
    note_names = dict([
        (0, "C"), (1, "C#"), (2, "D"), (3, "D#"), (4, "E"), (5, "F"), 
        (6, "F#"), (7, "G"), (8, "G#"), (9, "A"), (10, "A#"), (11, "B") ])
    # Print the notes
    for pc, count in reversed(sorted(pcs.items(), key=lambda x:x[1])):
        print "%s: %d" % (note_names[pc], count)
    
    if options.key_profile is not None:
        kp_output_file = "key_profile"
        pc_names = ["1", "#1/b2", "2", "#2/b3", "3", "4", "#4/b5", "5", 
            "#5/b6", "6", "#6/b7", "7"]
        # Output the pitch counts
        key = options.key_profile
        # Get the pc frequencies
        pc_freq = [float(pcs[(key+p)%12])/sum(pcs.values()) for p in range(12)]
        # Output them to a CSV
        data = "\n".join("%d\t%s\t%f" % (i,name,freq) for (name,freq,i) in zip(pc_names,pc_freq,range(12)))
        with open("%s.csv" % kp_output_file, 'w') as f:
            f.write(data)
        # Output the Gnuplot script
        gnuplot = """\
set style data lines
set nokey
set xrange [-1:13]
set terminal pdf monochrome
set output "key_profile.pdf"
set xlabel "Pitch class"
plot "key_profile.csv" using 1:3:xticlabel(2)
"""
        with open("%s.p" % kp_output_file, 'w') as f:
            f.write(gnuplot)
        # Run Gnuplot
        call(["gnuplot", "%s.p" % kp_output_file])
        print "Gnuplot plot output to %s.p and %s.pdf" % (kp_output_file,kp_output_file)
开发者ID:johndpope,项目名称:jazzparser,代码行数:60,代码来源:notes.py


示例20: create_record

def create_record(filename, include_data = False):
    print "Creating record", filename
    record = {}
    record["id"] = generate_id(open(filename, "rb"))
    record["filename"] = filename

    try:
        pattern = midi.read_midifile(filename)
    except:
        print "Error"
        return None
    
    if include_data:
        record["data"] = midiutil.midi_to_data(pattern)
    record["time_signature"] = midiutil.get_time_signature(pattern)
    record["tempo"] = midiutil.get_tempo(pattern)
    record["track_names"] = midiutil.get_track_names(pattern)
    record["resolution"] = pattern.resolution
    record["note_distribution"] = midiutil.get_note_distribution(pattern,[9])
    record["key"] = midiutil.guess_key(pattern, record["note_distribution"])
    record["scale"] = midiutil.guess_scale(record["key"], record["note_distribution"])
    

    #for track in pattern:
    #    print midiutil.get_track_name(track)
    #    dist = midiutil.get_note_distribution(track, [], False)
    #    plt.bar(range(len(dist)), dist.values(), align="center")
    #    plt.xticks(range(len(dist)), dist.keys())
    #    plt.show()

    # dist = record["note_distribution"]
    

    return record
开发者ID:b0rkestra,项目名称:b0rkestra,代码行数:34,代码来源:mididb.py



注:本文中的midi.read_midifile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python midi.write_midifile函数代码示例发布时间:2022-05-27
下一篇:
Python service.ValidationErrors类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap