RTMIDI........

Started by wadmixfm, July 21, 2019, 22:08:55

Previous topic - Next topic

wadmixfm

hello again

i am currently updating my old version of Specdrum which is a drum machine sequencer which was written by 2 guys called A.pateman & P Hennig of cheetahsoft days 1985

just recently they have released a newer version of Specdrum for Android devices etc.....

so i thought i would update my version of the 1985 original with a few extras , like mixer , tuning , midi , auto play , sorry i will get on with the question now :)

i am or have added RtMidi to the program and it works great but i am having one little issue

is there a way to change the midi out channel with RtMidi ??

when i use the code which is wrapped by brucey henderson it only plays on channel 1

most synths or drum machines have a dedicated channel 10 midi in

is this possible ???

sorry to be long winded there :)

here are some pics of my sequencer running :)



Lee B

Brucey

Hello, apparently the channel is encoded into midi message.

There's a bit about it here : https://github.com/SpotlightKid/python-rtmidi/issues/38#issuecomment-448655644

Yellownakji

I'm surprised RTMIDI works to begin with...

Never got it to function in my life.

iWasAdam

Yep, As Brucey says: You will need to decode the Midi messages. Both for sending and receiving.

RTMidi just gives you access to the data stream. Everything else you need to code.

One thing I noticed is that when first activating Midi (scanning) there will be a pause before program control is returned. So it might be a good idea for you to give users the option to activate when they want and not when the app starts - thus preventing a pause!

Midi data itself isn't complicated. but you will need to do some bit level stuff on bytes and nibbles...

wadmixfm

Thanks for the info and replies

i used portmidi before and that was in the message data too i will have a look at the info cheers Brucey

i have created a midi menu page at the top of my program now so the user can select the midi device in the list and then in the program you can turn the midi out on and off

cheers

i have got it really close to the original :)

1 more little question

which is the best audio driver to use for audio output with regards to latency ??? OpenAl or just direct sound nowadays

at the moment i am using Freeaudio and it seems to be ok

Lee

Yellownakji

Personally, i always use DirectSound for Windows and FreeAudio for Macintosh and Linux.  For Windows, FMOD is also really good but will require to have an ugly DLL in your project folder, so i never touch it. 

wadmixfm

#6
I have worked out a few of the RTMidi control and program changes hope this helps


' Simple program to test MIDI output.

SuperStrict
Framework BaH.RtMidi
Import BRL.StandardIO

Local midiOut:TRtMidiOut = New TRtMidiOut.Create()

If midiOut.getPortCount() = 0 Then
   Print "No Output Ports"
   End
End If

For Local i:Int = 0 Until midiOut.getPortCount()
   Print "  Output port #" + i + " : " + midiOut.getPortName(i)
Next

Print "Opening " + midiOut.getPortName()

midiOut.openPort(2) ' this is my midi device , you will have to check for your own :)


Local message:Byte[] = New Byte[3]

' Send out a series of MIDI messages.

' Program change ( Midi channel , value)
' 192 = ch 1 , 5 =  Elec Piano 2
' 193 = ch 2
' 194 = ch 3
' 195 = ch 4
' 196 = ch 5
' 197 = ch 6
' 198 = ch 7
' 199 = ch 8
' 200 = ch 9
' 201 = ch 10 *Note* Gm drumkits patch numbers are 0 = standard , 8 = room set , 16 = power set , 24 electric set , 25 Tr808 set ,32 = jazz set , 40 = Brush set ,48 = Orch set
' 202 = ch 11
' 203 = ch 12
' 204 = ch 13
' 205 = ch 14
' 206 = ch 15
' 207 = ch 16


message[0] = 201 ' this is channel 10 , i used this on my drum module
message[1] = 0 ' this is my standard kit
midiout.putMessage(message, 2)

message = New Byte[3]
' control change ( Midi channel , control , value)
' 176 = ch 1 , 7 = Vol , 100 (0-127)
' 177 = ch 2 , 10 = Pan , 64 (0 - 64 - 127) 0 left / 64 center / 127 right
' 178 = ch 3
' 179 = ch 4
' 180 = ch 5
' 181 = ch 6
' 182 = ch 7
' 183 = ch 8
' 184 = ch 9
' 185 = ch 10
' 186 = ch 11
' 187 = ch 12
' 188 = ch 13
' 189 = ch 14
' 190 = ch 15
' 191 = ch 16

message[0] = 185 ' this is channel 10
message[1] = 7 ' control change 7 for volume there are others 10= pan 91=reverb 93=chorus
message[2] = 120 ' volume is now set to 120
midiout.putMessage(message, 3)

message = New Byte[3]

' Note On: 144, 64, 90
' Note on  ( Midi channel , note , velocity)
' 144 = ch 1 , 36 = C 2 , 100 (0-127)
' 145 = ch 2
' 146 = ch 3
' 147 = ch 4
' 148 = ch 5
' 149 = ch 6
' 150 = ch 7
' 151 = ch 8
' 152 = ch 9
' 153 = ch 10
' 154 = ch 11
' 155 = ch 12
' 156 = ch 13
' 157 = ch 14
' 158 = ch 15
' 159 = ch 16

message[0] = 153 ' this is channel 10
message[1] = 36 ' C 2 on a keyboard or Kick drum on a drum module
message[2] = 100 ' velocity set to 100
midiout.putMessage(message, 3)

Delay(500)

message = New Byte[3]

' Note Off: 128, 64, 40
'note off 128 = clear note data , Note 36 = C2 ,Velocity 40
'as long as the note you used in note on make sure the note is used after the code 128 to clear that note

message[0] = 128
message[1] = 36
message[2] = 40
midiout.putMessage(message, 3)

message = New Byte[6]
' Sysex: 240, 67, 4, 3, 2, 247
message[0] = 240
message[1] = 67
message[2] = 4
message[3] = 3
message[4] = 2
message[5] = 247
midiout.putMessage(message, 6)

midiout.free() ' lets close the midi port


Lee

Hezkore

This may be totally unrelated to this thread, and if so I'm sorry.
But I'm curious...
How hard would it be to read Midi files and then manually play them via something like the 'Microsoft GS Wavetable Synth'?
I'd also like to read the Midi data my keyboard/synth outputs and make some sort of music game out of it.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

wadmixfm

well it can be done but in my instance i am just using midi out from a drum based sequencer i am reviving :)

so all i am using the midi for is a trigger to send to a drum module to play the sounds and in the program i am writing i can use the samples in the program as well

RTmidi ..... seeems quite well documented and i dont know how far you want to go with it but for me its pretty damn good.

my sequencer just uses note on note off velocity volume pan and effect send to reverb and chorus and as you can see from the example i have posted i have documented the out status

the only thing about rtmidi and i think with portmidi too you have 3 bytes (message 0 ) is the channel , (message 1) is the note or control , (message 2) is the value

thats all i have used

have fun and i hope it helps

lee


wadmixfm

and i think someone posted not long ago about midi files , you could use fmod as that has a midi file reader in its code

maybe look at that :)

Lee


wadmixfm

here are some little screenshots from my attempt at an old conversion of specdrum from 1985 , i have contacted A.pateman and P.Hennig the original coders of specdrum and they want me to send them a complete version of this :)

Good old Cheetahsoft :)

Lee  :P


Hezkore

#13
I'm having quite the delay using the Microsoft GS Wavetable Synthesizer.
Anyone know of a workaround?

Been looking at this, but I'm confused: https://github.com/KeppySoftware/OmniMIDI/blob/master/DeveloperContent/KDMAPI.md
And it seems like people use the old bassmidi.dll to basically emulate the MS GS wavetable synth, just with a lot less delay.

I'd like to avoid having people install third party apps and sound fonts, just to get rid of the delay.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

iWasAdam

what sort of delay?
initial connection to RTMidi when first scanning may have a delay of a few seconds or more. but once connected everything is 1:!