Hi! I am just starting with Scamp. Is there a way to save the score directly to a MIDI file?
Thanks
Frank
Hi! I am just starting with Scamp. Is there a way to save the score directly to a MIDI file?
Thanks
Frank
Hi Frank, good to meet you!
Saving the score to MIDI isn’t implemented yet, unfortunately. What I do is route the midi to a DAW and then record it.
That said, you’re not the first person to ask, and it’s a priority in the next few months to add this feature!
Hello also just now joining. And, if I may, I’ll be the nth scampster to ask about exporting midi files to import in a DAW. Happy to be here.
Welcome!
I’ll definitely get to it… it’s hard because of all of the capability I built into SCAMP with respect to pitch bending and volume expression, which requires juggling a bunch of separate MIDI tracks. All that code is wrapped up in the live playback code, and so it’s a bit of a job to retool it for generating a MIDI track.
In the meantime, though, it really does work well to just use s.new_midi_part(name_of_part, name_of_midi_device)
to send live MIDI to a DAW, and then press record!
Hello,
I’m a new SCAMP user – very glad to be here with you.
I don’t know if by now the save-to-MIDI feature exists, but a simple workaround is to save to Lilypond and then add the section declaring the use of MIDI to the Lilypond file.
A simple code such as the following one does the trick.
All the best,
Eidon
#!/usr/bin/env python
import sys
try:
file = sys.argv[1]
with open(file) as f:
lines=f.readlines()
except:
print(f'Usage: {sys.argv[0]} file.ly')
sys.exit(1)
sought_line = 0
instr_lines = []
for n, line in enumerate(lines):
if 'tempo' in line:
tempo_line = line
if '>>' in line:
sought_line = n
if 'instrumentName = #' in line:
instr_lines.append(n)
with open('patched-'+file, 'w') as g:
g.writelines(lines[:instr_lines[0]+1])
line = lines[instr_lines[0]]
line = line.replace('instrumentName', 'midiInstrument')
line = line.replace('piano', 'Acoustic Grand')
g.write(line)
g.writelines(lines[instr_lines[0]+2:instr_lines[1]+1])
line = lines[instr_lines[1]]
line = line.replace('instrumentName', 'midiInstrument')
line = line.replace('piano', 'Acoustic Grand')
g.write(line)
g.writelines(lines[instr_lines[1]+2:instr_lines[2]+1])
line = lines[instr_lines[2]]
line = line.replace('instrumentName', 'midiInstrument')
line = line.replace('piano', 'Acoustic Grand')
g.write(line)
g.writelines(lines[instr_lines[2]+2:sought_line+1])
print('\\midi {', file=g)
print(' \\context {', file=g)
print(' \\Staff', file=g)
print(' \\remove "Staff_performer"', file=g)
print(' }', file=g)
print('\\context {', file=g)
print(' \\Voice', file=g)
print(' \\consists "Staff_performer"', file=g)
print(' }', file=g)
# print(f' {tempo_line}', file=g)
print(' }', file=g)
g.writelines(lines[sought_line+1:])
print(f'End of processing. Output is in file patched-{file}')
Sorry, this had to be
g.writelines(lines[instr_lines[0]+1:instr_lines[1]+1])
Hi, new to programming, python etc.
I was trying chatGPT to write some code, it seems it doesn’t work…
maybe you can help?
import math
import random
import scamp
# Create a new MIDI file
s = scamp.Scamp(tempo=600000, time_signature='4/4')
# Set the instrument to a piano
s.program_change(0)
# Define the golden ratio
phi = (1 + math.sqrt(5)) / 2
# Define the number of notes to generate
num_notes = 32
# Generate the pitches using the golden ratio
pitches = [60 + (i * phi) % 12 for i in range(num_notes)]
# Add the notes to the track
for pitch in pitches:
# Choose a random duration for the note
duration = random.randint(8, 32)
# Choose a random velocity for the note
velocity = random.randint(1, 127)
# Add the note to the track
s.note_on(0, pitch, velocity, duration)
# Save the MIDI file
s.write('golden_ratio_music.mid')
best, vime
Lol, I actually tried the same thing with chat GPT, and it seems to have invented its own music library called Scamp that bears no relation my own. Or at least if it didn’t invent it, I can’t figure any reference to a Scamp Library that works the way it thinks it does
Very interesting! I tried something similiar with chatGPT and mido (which worked partially). How would this be done with your library?
What are you trying to do?