Petr Schreiber
17-10-2014, 20:44
... did you ever wondered, how productive you would be in writing anything, if every touch to the keyboard would cause different sound?
No?
Well, that indicates you are... sane :) But just in case, try this script:
Uses "WinMM", "UI"
Begin Const
%MIDI_ChangeInstrument = 192
%MIDI_NoteOn = 144
%MIDI_NoteOff = 128
End Const
Function TBMain()
Long hmidiOut
Long instrument, duration, note, i
Single velocity
velocity = 50
note = 50
duration = 4
Long Device = 0
Long tNow, tLast
MidiOut_Close hmidiOut
If MidiOut_Open hmidiOut, 0, Device, 0, 0 <> 0 Then
MsgBox 0, "Unable to open MidiOut port!"
Exit Function
End If
tLast = GetTickCount
Do
tNow = GetTickCount
For i = 1 To 255
If GetAsyncKeyState(i) Then
velocity = Rnd(0,127)
note = Rnd(0,127)
instrument = Rnd(0,127)
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_ChangeInstrument, instrument, 127)
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_NoteOn, 12 + note, velocity)
Sleep duration
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_NoteOff, 12 + note, 127)
tLast = GetTickCount
End If
Next
If GetAsyncKeyState(%VK_ESCAPE) Then
Exit Do
End If
Loop
MidiOut_Close hmidiout
End Function
Once the headache comes, simply press ESC anytime, and the keyboard will stop doing those... noises.
Have a nice weekend!,
Petr
P.S. Tip: Do not run this script from thinAir, but launch it by clicking. This will allow smooth thinAir "experience"
No?
Well, that indicates you are... sane :) But just in case, try this script:
Uses "WinMM", "UI"
Begin Const
%MIDI_ChangeInstrument = 192
%MIDI_NoteOn = 144
%MIDI_NoteOff = 128
End Const
Function TBMain()
Long hmidiOut
Long instrument, duration, note, i
Single velocity
velocity = 50
note = 50
duration = 4
Long Device = 0
Long tNow, tLast
MidiOut_Close hmidiOut
If MidiOut_Open hmidiOut, 0, Device, 0, 0 <> 0 Then
MsgBox 0, "Unable to open MidiOut port!"
Exit Function
End If
tLast = GetTickCount
Do
tNow = GetTickCount
For i = 1 To 255
If GetAsyncKeyState(i) Then
velocity = Rnd(0,127)
note = Rnd(0,127)
instrument = Rnd(0,127)
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_ChangeInstrument, instrument, 127)
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_NoteOn, 12 + note, velocity)
Sleep duration
MidiOut_ShortMsg hmidiOut, Rgb(%MIDI_NoteOff, 12 + note, 127)
tLast = GetTickCount
End If
Next
If GetAsyncKeyState(%VK_ESCAPE) Then
Exit Do
End If
Loop
MidiOut_Close hmidiout
End Function
Once the headache comes, simply press ESC anytime, and the keyboard will stop doing those... noises.
Have a nice weekend!,
Petr
P.S. Tip: Do not run this script from thinAir, but launch it by clicking. This will allow smooth thinAir "experience"