File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from ctypes import *
44import signal
55import sys
6+ import time
67
78MonikaDLL = cdll .LoadLibrary (os .getcwd () + '\\ MonikaDLL.dll' )
89MonikaDLL .get_my_driver_handle .restype = c_uint8
@@ -16,6 +17,7 @@ def signal_handler(sig, frame):
1617 print ('You pressed Ctrl+C!' )
1718 MonikaDLL .MonikaBeepStop ()
1819 sys .exit (0 )
20+
1921signal .signal (signal .SIGINT , signal_handler )
2022
2123# Function to convert MIDI note number to frequency (Hz)
@@ -28,11 +30,13 @@ def play_beep_for_midi(note, duration_ms):
2830 frequency = int (midi_note_to_freq (note )) # Convert MIDI note to frequency
2931 print (f'Playing note { note } at { frequency } Hz for { duration_ms } ms' )
3032 MonikaDLL .MonikaBeepStart (frequency ) # Start beep
33+ time .sleep (duration_ms / 1000 ) # Sleep for duration
34+ MonikaDLL .MonikaBeepStop () # Stop beep
3135
3236# Read MIDI file
3337def play_midi_beep (file_path ):
3438 mid = mido .MidiFile (file_path )
35- tempo = 500000 # Default tempo (microseconds per beat)
39+ tempo = 50000 # Default tempo (microseconds per beat)
3640
3741 for msg in mid .play ():
3842 if msg .type == 'note_on' and msg .velocity > 0 : # Play note
You can’t perform that action at this time.
0 commit comments