Esempio n. 1
0
 def play(self):
     self.save()
     player = sound.MIDIPlayer(self.name + '.mid')
     player.play()
     while player.current_time < player.duration + 1:
         pass
     player.stop()
Esempio n. 2
0
 def webview_should_start_load(self, webview, url, nav_type):
     if url.endswith('.mid'):
         fname = url.split('/')[-1]
         fname = os.path.join(os.path.expanduser('~/Documents/Downloads'),
                              fname)
         http = urllib3.PoolManager()
         response = http.request('GET', url)
         with open(fname, 'wb') as f:
             f.write(response.data)
         webview.p = sound.MIDIPlayer(fname)
         webview.p.play()
         return False
     return True
Esempio n. 3
0
def play_pause(sender):
	global song, player, rate, position
	if sender.playing:
		sender.image = ui.Image.named('iob:ios7_play_outline_256')
		sender.playing = False
		position = player.current_time
		rate = player.rate
		stop()
	else:
		sender.image = ui.Image.named('iob:ios7_pause_outline_256')
		sender.playing = True
		write_midi(song)
		player = sound.MIDIPlayer('output.midi')
		player.rate = get_subview('tempo_slider').value + 0.5
		player.current_time = position
		play()
def play_pause(sender):
	global song, player, rate, position
	if playing():
		sender.title = 'Play'
		position = player.current_time
		rate = player.rate
		stop()
	else:
		sender.title = 'Pause'
		write_midi(song)
		player = sound.MIDIPlayer('output.midi')
		# obc_player = objc_util.ObjCClass('AVMIDIPlayer')
		# obc_player.init('output.midi', None)
		adjust_time(get_subview('time_adjuster'))
		play()
		player.rate = get_subview('tempo_slider').value + 0.5
Esempio n. 5
0
    transpose.append(key)
music = transpose

play = []
for t in range(len(music)):
    pitch = music[t]
    play.append(pitch)
    # track, channel, pitch, time, duration, volume
    midi.addNote(0, 0, pitch, t * duration, duration, 100)

# Write output file:
with open('output.mid', 'w') as f:
    midi.writeFile(f)

# Play the result:
player = sound.MIDIPlayer('output.mid')
pla = int(1)
dur = 2
nos = [1, 2, 3]
with open('output.mid', 'w') as f:
    midi.writeFile(f)
place = sound.MIDIPlayer('output.mid')
place.play()
player.play()

# Time and Learning
wait_time = int(len(music) / (original_speed / 60)) + .5
start = time.time()

performance = 1
while performance != 0:
Esempio n. 6
0
for pitch in degrees:
    MyMIDI.addNote(track, channel, pitch, time, duration, volume)
    time = time + 1

#MyMIDI.addProgramChange(track, channel, time, mc.Xylophone)

for pitch in degrees:
    MyMIDI.addNote(track, channel, pitch, time, duration, volume)
    time = time + 1

#MyMIDI.addProgramChange(track, channel, time, mc.Tubular_Bells)

for pitch in degrees:
    MyMIDI.addNote(track, channel, pitch, time, duration, volume)
    time = time + 1

#MyMIDI.addProgramChange(track, channel, time, mc.Music_Box)

for pitch in degrees:
    MyMIDI.addNote(track, channel, pitch, time, duration, volume)
    time = time + 1

with open("major-scale.mid", "wb") as output_file:
    MyMIDI.writeFile(output_file)
    
player = sound.MIDIPlayer("major-scale.mid")
player.play()
#sound.play_effect('arcade:Laser_4')

Esempio n. 7
0
import sound

file = input('Enter file name\n')

player = sound.MIDIPlayer('{}.mid'.format(file))
player.play()
Esempio n. 8
0
	def prepare_next(self):
		self.p = None
		self.path = self.next_file()
		if self.path:
			self.p = sound.MIDIPlayer(os.path.expanduser(self.path))