kroger / pyknon

Simple Python library to generate music in a hacker friendly way.
http://kroger.github.com/pyknon/
MIT License
391 stars 48 forks source link

volume vs velocity #14

Closed alienbeatpoet closed 3 years ago

alienbeatpoet commented 8 years ago

i’m trying to affect each particular note’s velocity. i thought maybe you were using ‘volume’ where you meant ‘velocity’, but that appears to not be the case.

i have a loop that is generating new Note() instances, but i can’t seem to affect the velocity or volume. the result is basically the following:

Note(value=A, octave=3, volume=101)
Note(value=B, octave=5, volume=68)
Note(value=E, octave=4, volume=86)
Note(value=C, octave=5, volume=71)
Note(value=E, octave=3, volume=104)
Note(value=B, octave=5, volume=65)
Note(value=C, octave=3, volume=85)
Note(value=A, octave=5, volume=74)

however, when the midi file is written out (see attached) and opened in Logic Pro X all the notes are correct, however they all have a velocity of 120 and no indication of change in volume anywhere.

where is the velocity being set to a value of 120? and where is the volume value being used?

tracks.mid.zip

kroger commented 8 years ago

Hi,

Volume is the proper musical term, whereas velocity is MIDI jargon (since it was developed with keyboard in mind). Setting the volume keyword will affect the MIDI velocity, as you thought.

The volume keyword seems to be working here, on a Mac. I heard some people having problems on Windows.

Could you, please, try to run the following code and see if it works? It will generate one note with the velocity of 68:

#!/usr/bin/env python

from pyknon.genmidi import Midi
from pyknon.music import Note

notes1 = [Note(value=0, octave=3, volume=68)]
midi = Midi(1, tempo=90)
midi.seq_notes(notes1, track=0)
midi.write("demo.mid")

As you can see, it works here:

note

Maybe Logic doesn't like the Midi file pyknon generates?