Playing a MIDI file by tapping two keys

Hi!

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.

/Martin

For this you need a GP Script.

Welcome to our Community! :slight_smile:

Ok, then I have to start scripting :slight_smile:

Thank’s for that link. I will check it out and see if I can find it here. Is there

This should be the script → LINK.

No….in this case tapping is used simply to step through the MIDI file with each tap representing a quarter note or eighth note, etc

Ok, well I will try it out and se if I can use this.
I will report back when I have done some testing

It took me a while but I finally got it to work :smile:!
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…).

1 Like

Perhaps you can share your work so other Windows users can reuse it? :slight_smile:

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.

2 Likes

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 :slight_smile:

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

screenshot_6258

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.

Could you be so kind to upload the whole rackspace, it would make it easier to work with it for the first time.
Thanks in advance
Flodder