Hy,
I try to make an instrument where I can play my midi files. I tried and found some code and testet it but I had no luck. Here is a code I found but if I press the play button nothing happens. The midi files are loaded.
on ui_control ($play)
if ($play = 1)
end if
end on
on listener
$cur_listener_id := $NI_CALLBACK_ID
if ($play = 1)
if ($mf_length = -1)
mf_get_last($TRACK_IDX)
$mf_length := mf_get_pos()
end if
if ($prev_ext_song_pos = $NI_SONG_POSITION)
$cur_song_pos := $cur_song_pos + $LISTENER_BEAT_LENGTH_TICKS
else
$cur_song_pos := $NI_SONG_POSITION
end if
$prev_ext_song_pos := $NI_SONG_POSITION
mf_get_next_at($TRACK_IDX, $cur_song_pos mod $mf_length)
$end_of_beat := $cur_song_pos mod $mf_length + $LISTENER_BEAT_LENGTH_TICKS
$last_pos := $cur_song_pos mod $mf_length
while (mf_get_pos() < $end_of_beat and $play = 1 and $cur_listener_id = $NI_CALLBACK_ID)
if (mf_get_command() = 0)
$end_of_beat := $end_of_beat mod $mf_length
mf_get_first($TRACK_IDX)
$diff := $mf_length - $last_pos + mf_get_pos()
else
$diff := mf_get_pos() - $last_pos
end if
if (ticks_to_ms($diff) > 0)
wait_ticks($diff)
end if
if ($play = 1)
play_note(mf_get_byte_one(),mf_get_byte_two(),0,0)
end if
$last_pos := mf_get_pos()
mf_get_next($TRACK_IDX)
end while
end if
end on
Can you help me please?
Thanks a lot
Kind Regards Roman