For some time ago I found a video on youtube about GigPerformer. In this video he was playing a importet midi file. He did this by tapping two keys on the keyboard (I think he used this to set the tempo the file was played in). Now I can’t find that video or who did it.
Is there any one who can give some help or point me in the right direction to solve this.
I could really have som good use for this function if it’s possible.
It took me a while but I finally got it to work !
This have probably to do with that this was my first attempt with GPScript.
I’m doing this on a windows computer and I found that the search way to the file have to be written with slash not backslash. So as I do normally in windows (c:\folder\folder\folder…) didn’t work, hade to be written (c:/folder/folder…).
Her is the script tha works for me on a Windows computer:
var
trackCount: Integer
Keyboard : MidiInBlock
LeadSynth : MidiInBlock
cs : MidiSequence
initialization
trackCount = MidiSequence_LoadMidiFile(cs, "C:/test/play_midi.mid")
Print(trackCount)
MidiSequence_Quantize(cs,2)
MidiSequence_MapOutputChannel(cs, 2, 4)
end
On NoteEvent(m: NoteMessage) Matching [C1..D1], B-1 from Keyboard
var
notes: MidiMessage Array
aNote: MidiMessage
index: integer
trackIndex: integer
if IsNoteOn(m)
then
if MidiSequence_EndOfSong(cs) or m.GetNoteNumber()==B-1
then MidiSequence_ResetToStart(cs)
end
MidiSequence_CollectEventsNow(cs);
notes=MidiSequence_GetCurrentEvents(cs, 1)
for index=0; index<Size(notes); index=index+1 do
aNote=notes[index]
//LeadSynth
PlaySequenze.SendNow(aNote)
end
end
end
On NoteEvent(m:NoteMessage) Matching A-1 from LeadSynth
MidiSequence_ResetToStart(cs)
AllNotesOff(LeadSynth)
end
As I mentioned earlier in this this thred, use slash (/) in the path to the midi file.
The use of the backslash as a path separator is a consequence of the forward slash having been used for DOS command line arguments when DOS was first developed. There was no such concept as a directory. Because of this, when they added directories, they couldn’t use the forward slash as a path separator so they used the backslash consequently confusing the entire world, specially when it comes to defining URLs, all of which use forward slashes in paths
You don’t normally do that inside a programming language! For example, in Windows Explorer you don’t put quotes around the path. See example here
But inside a programming language, things are completely different. The backslash (if defined in a particular language) has a completely different purpose. Unless a particular language itself understands the concept of paths, then you represent paths as strings complete with quotes around strings and you normally use forward slashes as path separators.