from midiutil import MIDIFile ############################################################ #### Python script created by Jeet: (5 Minutes Blender) #### ### Change the following two lists with correct values, ### based on your animation and the sound requirements. frame_numbers = [17, 34, 46, 56, 66, 77] sound_notes = [96, 100, 103, 107, 110, 90] # Change the following fps as appropriate for your animation. # The most common values are 24 and 30, often 60 is also used. fps_rate = 24 output_path = "C:\MyTest\sound.mid" duration = 0.1 # In beats tempo = 120 # In BPM volume = 100 # 0-127, as per the MIDI standard ### No need to change anything below this line. ############################################################ track = 0 channel = 0 time = [] for i in range(len(frame_numbers)): time.append(frame_numbers[i]*2/fps_rate) MyMIDI = MIDIFile(1) MyMIDI.addTempo(track, time[0], tempo) for i, pitch in enumerate(sound_notes): MyMIDI.addNote(track, channel, pitch, time[i], duration, volume) with open(output_path, "wb") as output_file: MyMIDI.writeFile(output_file)