SK-Ray / skSynth

Synth Module for CoronaSDK
3 stars 2 forks source link

Changing bpm #1

Open Samelot opened 10 years ago

Samelot commented 10 years ago

Hey, this isn't an issue with your code..

I'd just really like to figure out how to change the bpm. I know were using midi.lua to somehow convert these midi files to something we can use to play. So I suppose that one could either - alter the tempo of the midi before being written to the file that is played back, OR alter the tempo of the play back. I'd like to do the latter (alter playback speed).

Do you know how this might be possible?

The only way I was able to change the tempo was going into MIDI.lua and change line 1106 from:

local my_opus = {ticks,}

to

local my_opus = {500,}

Other than that, I'm pretty lost. I'm sure there is a better way to do this, hopefully just by passing in parameters in SKCoronaSynth.lua.

Thanks

SK-Ray commented 10 years ago

@Samelot Thanks for your interest! I finally get to dust off this code :)

In SKCoronaSynth.lua , the local listener function can be modified to multiply the delta Time by some factor, such as .5 (to slow down by 50%), or 2 (to double speed). You would then want to divide your duration by that same value, otherwise notes may start overlapping when you speed up your playback.

Since MIDI files can have multiple tempo changes, all tempo changes would probably also be affected by that factor.

I am working on a function to let you directly set the tempo in beats per minute. It should allow you to change BPM before or during playback.

I found this article helpful, but wound up having to multiply the value for the set_tempo event by .1 https://groups.google.com/forum/#!topic/music21list/f9AboXHW0QE

Samelot commented 10 years ago

That certainly works! I appreciate the help. I'll check out that article now

Sam

On Sun, Jul 13, 2014 at 1:04 AM, SK-Ray notifications@github.com wrote:

@Samelot https://github.com/Samelot Thanks for your interest! I finally get to dust off this code :)

In SKCoronaSynth.lua , the local listener function can be modified to multiply the delta Time by some factor, such as .5 (to slow down by 50%), or 2 (to double speed). You would then want to divide your duration by that same value, otherwise notes may start overlapping when you speed up your playback.

Since MIDI files can have multiple tempo changes, all tempo changes would probably also be affected by that factor.

I am working on a function to let you directly set the tempo in beats per minute. It should allow you to change BPM before or during playback.

I found this article helpful, but wound up having to multiply the value for the set_tempo event by .1 https://groups.google.com/forum/#!topic/music21list/f9AboXHW0QE

— Reply to this email directly or view it on GitHub https://github.com/SK-Ray/skSynth/issues/1#issuecomment-48833644.