Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / Midi Plugin

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 26th Dec 2007 00:29 Edited at: 5th Aug 2008 23:32
***** Update 05/08 2008 *****
The midiIn seems to finally work properly; no more lost messages judging by my tests.
I've also added a new "parsing" system, complete with an include file, which allows you to easily extract any kind of information from an midi message. I've also fixed a few bugs and shaped up the documentation again.
Also, for the first time ever, I have supplied a proper, commented demonstration source.
See further info in post 37 and download the update.
***** *****

***** Update 27/07 2008 *****
The midiIn buffer purging has been updated in order to deal with the issue of certain messages getting lost during processing.
See post 32 for further info.
Download updated version
***** *****

***** Update 01/06 2008 *****
Slightly updated version attached due to SMD_3D_Interactive's QMidi project.
I've shaped up the helpfiles a bit and added a new command; set sustain pedal.
The installer is still the same though, so the files might need to be moved manually.
***** *****

Cheers, any readers.
I posted a demo of this before; the interrest wasn't very big though (not that you could really expect it for such a thing as this either) and hence I haven't really done anything more about this the last months, as it does all that my needs require of it allready.

However, my demo version was time limited and set to expire in the middle of December.
Therefore, I decided to realease the plugin as-is, with removed restrictions.

Not to worry; it is fully functional - the only things I might have done about it otherwise would have been to add some additional "for convenience"-commands, maybe enhance the helpfiles a bit and tried to optimize the code.

Most things you would need to do can be done directly by using your own midi messages (which are usually words consisting of 3 bytes); use the command SEND MIDI SHORTMSG and get most info you'd need here http://users.chariot.net.au/~gmarts/midimsg.htm.


Key features:
♦MidiOut control
Send midiOut data over any available port on your system. Port listings, volume control, instrument selection, etc. has separate, easy to use commands (saves you some time from having to write your own shortMsg's for it).

♦MidiIn control
Retrieve midiIn ports (adresses and names), collect midiIn events as shortMessages (3-byte words) - you can then parse theese however you like, and so on.

♦Possibility to trigger the computers built-in oscillator
Allright, this might not be all that usefull in the sequencing terms, but I threw in the Beep-function from kernel32 as well.
It could turn out to be of use in some app/game you'll write, who knows?


~~~~~~~~~~~~~~~~~
Attached is the plugin, helpfiles, the keyword files and a program that gets everything set up for you (it even appends the commands.html file, adding Midi-commands to it's end), while you play the banjo using your midi-controller.

If you don't dare to use the installer (maybe I've been isolated in my basement with a german, a taliban, two japaneses and a cat, writing the most vile malware ever seen to this day and now decided to spread it - in the perfect disguise; a midi-plugin installer! - after two years of febrile development), you could just move the files yourself.

Midi_Plugin.dll goes into DBPRO_ROOTCompilerplugins_user,
midi_includes.dba to whereever you'd like to have it (the installer puts it in DBPRO_ROOTProjects),
MidiKeywords.ini are headed for DBPRO_ROOTEditorKeywords,
midi.html should be placed in DBPRO_ROOTHelpcommands.
Finally, copy the midi folder to DBPRO_ROOTHelpcommands.

I hope that someone will find this useful; merry holidays

"I kören hörs de brummande busarna Björnligan och Gondolen"

Attachments

Login to view attachments
code master
20
Years of Service
User Offline
Joined: 4th Dec 2003
Location: Illinois
Posted: 29th Dec 2007 20:49
I'm having fun with this, very nice.

Now I just have to figure out how to set up a timing system.

BTW, your installer dosn't copy the keywords file or the individual help files.

thebulk71
18
Years of Service
User Offline
Joined: 2nd Jan 2006
Location: takin a poop
Posted: 30th Dec 2007 19:57
This actually has enormous potential... I take it that it uses the detected windows media hardware (ex: a USB keyboard )?

I am gonna go have some fun experimenting with this.

cheers
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Jan 2008 00:16
@code master: I'm pleased to hear that
I'm going to look into the installer then... I don't have it here at the moment though.

@thebulk71: Again, nice to hear it is appreciated.
And yes, that's what it does.

I might add a timer system in there, if I ever get one to work too.

"I kören hörs de brummande busarna Björnligan och Gondolen"
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Jan 2008 23:22
Here's a small, commented demo, demonstrating a simple way of recording and playing back a midi sequence.



Please note that this is not optimized, but aimed more at being easy to understand.

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 27th Apr 2008 18:36 Edited at: 27th Apr 2008 18:36
Rudolpho: This midi plugin was your creation?

I have used it in my free midi composer if thats ok?

Its in the music forums and its a work in progress....


i hope to be able to save my files in the midi format.

Thanks alot for this dll its a cool one: Can i make you a new install file to install this dll.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 27th Apr 2008 22:17 Edited at: 27th Apr 2008 23:07
Yes, it's mine.
I guess you can use it pretty much however you want. I would of course appreciate being mentioned in the credits

I looked up your Qmidi project (I take it that's the one?); it looks pretty good. I didn't really get the controls though (especially the slider instrument selection ), but I suppose they're just temporal.

About the file format, I was actually thinking of implementing it in a later version of this plugin; it's not that hard.
Basically you have to separate all midi messages in separate tracks (given your application you should know what a track is ) and specify a smallest time stamp - other than that it's really just a collection of messages and wait rates.
I could perhaps lend you a hand on this if you like.

Finally, the installer... yes, for some reason my project won't compile properly anymore, so I can't fix it... I'll have to rewrite it someday I guess. Chagrinning, as the error was a mistyped variable which resulted in a for loop running just one time.
Anyhow, all the files are included with the installer and most users will know how to do a standard plugin installation, so it will work for the time being as well.
Of course, if you don'y have anything better to do, you could write a new installer in the meantime

Edit: Just out of curiosity, what parts of the plugin are you making use of?

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 29th Apr 2008 07:16
im just using the note on and note off....lol
i guess the volume and pan and the modulation functions too

Do you want to help with this project to get the midi file save working? I just want everybody to have a free midi editor to make music for there games

I want to put you in the credits.....Just Rudolpho or do you have another name i should mention?

all of the bottom tool bar stuff was temporary just to get the thing working.

here is my code play back and maby you could figure out how we could save this all as a midi file.



if you want to try loading this song in here this is how to load the song

code snippet from qmidis file format for loading




if you could help out and give me some ideas or direction that would be great
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 29th Apr 2008 07:18
dim music(7000,10,27,3)
dim copy(64,27,3)
dim encript(9)
dim playin(120,10,1)
dim instrument(10)
dim vol(10)
dim pan1(10)
dim modual1(10)
for x=1 to 10
vol(x)=48
pan1(x)=3

next x

almost forgot those! lol
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 30th Apr 2008 02:28 Edited at: 30th Apr 2008 02:29
maby you could even just help me out on the midi comands in byte format......every example i seen is in hex and just sucks to decode
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Apr 2008 16:18 Edited at: 30th Apr 2008 16:26
Allright, I've looked into it, but your snippets lack some neccessary information. For instance, there's a lot of references to blueGui gadgets that I don't even know what they do (such as ed5); there's also some subroutines being called that you haven't posted.
I managed to get it to run with some tweaking, but it's still a bit hard to see just what every array item actually stores, etc.

Also, a midi file is divided into separate tracks. I guess that your Qmidi application write to different tracks, so where and how are they stored?

If you could add in the missing parts and comment this a bit, I might be able to help.

About the hexadecimal format, it's pretty easy.
Instead of a base of ten, sixteen is the base used.
Therefor, we have 16 digits (0 - F, where A = 10, C = 12, etc) instead of the standard 10 (0 - 9).
The byte ranges from 0 to 255, which is the full range of a two-digit hexadecimal value (FF = 255).
So, a midi message, which consists of three bytes, will have the hexadecimal repressentation 0xaabbcc, where aa is the first byte (00 = 0 to FF = 255), bb is the second and cc repressents the last byte.

So, let's take the standard note on message, for C3 (note id 60):
0xaabbcd (notice that the c and d are separated).
First out, we have 0xaa. For the note on message, this would be the attack velocity of the note, ranging from 0 to 127 (0x00 to 0x7F; think (16 * 7) + F = 112 + 15 = 127, where F = 15).
Next out, we have the second byte; 0xbb. For most standard midi operations, this will be the note number to play. As you know, there are 127 asumed midi keys and 0xbb is therefore represented by the values 0x00 through 0x7F. In this example, we arre to turn on C3, midi note 60. Therefor, the value of 0xbb would be 0x3C, as 60 = (3 * 16) + 12 = 48 + 12.
Then we have c. This is the control byte, or whatever you want to call it. The type of the midi message is dependant on the value of this byte.
For the note on event, the value is 9, which in hex will be 0x09. However, since this is only one digit of the two-digit byte, the value will simply be 0x9.
The last part, d, is then added last to this. D repressents the channel, ranging from 0 to 15 (0 to F). When combined, the last byte in a message to turn on a note on channel 9 would be 0xcd = 0x99.

So, in conclusion, the midi message to turn on note 60 is 0xaabbcd, where aa = velocity, bb = note number, c = note event and d = the cannel to be affected.
The message would thus be 0x7F3C99 to turn on note 60 with full velocity on channel 9.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I guess this was pretty fussy; feel free to ask about something in particular.

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 1st May 2008 07:54
ive been looking at alot of examples on line and they suck...lol

im just having a little trouble understanding how the commands are written... why you need a total byte count of a track when you put in a command saying end of track??

Just a few fuzzy problems.

as far as i understand this is what we have:
midi file format

`m,t,h,d :Mthd
`0,0,0,6 :bytes to follow
`0,0,0,1 :file format
`0,10 :number of tracks used

ok so i think the header im fine with

now the rest im foggy on

questions:
Is a track all written in from start to end Then proceeding to write the other tracks?

speed issues
im basing my tempo with clock cycles from the system timer
0 setting is actualy 500 ms :1/2 second
250 setting is 0 ms:as fast as the computer can process it

200-150 is the main range that i use when composing..

basicly this is how it works

tempo=180

500-(tempo*2) = process speed in milli seconds.

next to clear up how the song data is stored

music(notenumber,channel,notedraw,data)
note number is the playback order 0-your last note in the song loop

channel is from 1-10 also set up so track 1 uses channel 1,track 10 users channel 10

notedraw is the order of notes from top to bottom. i beleive it ranges 0-27

data ...ok this is where everybody gets confused just give me a sec to explain.

1) (0=type of note) 0=none 1=16 note playback length,2=half (8),3=1/4 (4), 4=1/8th note(2), 5=16th note lasting only 1 bar space

2) (2=note to play) eg music(25,1,20,1)=85 then it would play that note velocity is always set to 100 on play back

3) (1=internal editor data) that is not needed for playback



so this is how the main playback loop works





updatenotes
-check if its time to update if not return
-ready to update check if we are past the end of song

-look threw an array that is storing the values of notes already playing
-decrease the note counters for the length of play back on those note currently playing

-check all 10 tracks for notes to play
-if find note set it up in the playing notes array and how long it needs to play for and turn the note on
-return


thats it

it also sets instruments and pan and modulation in that loop as well

velocity is always set to 100


to me this just seems like a pain in the but...lol

id rather write an include file for people to use.
all they need to do is install your midi plugin. then add my include file to there app.

processing the music should not be harsh on the frame rate.

i think it would do very well.

the option of recording to wav file is there as well but if you dont know how to set up your recording to stereo mix then your SOL for that to work.

humm....

the include file would not be a bad idea....it would also give the option of the programer to make sound fx or hit notes when ever.

i will probly start setting it up that way for now

it is definetly possible to do midi file format but i should buy a book on it first...Any books that you would recommend?

Thanks
Im working on that bottom tool bar and making it much nicer without the track bars
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 1st May 2008 14:51
Yes, DBPro is a bit odd when it comes to writing the hexadecimal values; I just noticed that it writes them in reverse order to the files

I still don't really get the notedraw index; could you explain it in better detail?

About the include file, I don't think it would be a very good idea - you would most likely have to make it a separate thread to run as expected, I mean, try rendering a few Kpoly 3D scene with 250 frames per second... it won't work on my computer anyways, and if it doesn't, the music would be pretty slow or even hack.

About books, I don't know - I, for myself, have used the msdn documentation along with quite a few other internet sites.

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd May 2008 04:22 Edited at: 2nd May 2008 04:24
notedraw is the up/down editing on a music track

it will cycle threw to see if there is any notes to play...if not move forward on the track to play the next set of notes if they exist.

im looking at my frame rate and its very fast on the music play back.... I think an include file for dbpro would be good. I have done this with my wav playing editors and it seems to hold the speed of the song. I guess if you had real intense graphics it would slow down but for the most part i think an include file would be ok.

myframe rate on playback is about 450 fps

if i take out all the graphics and all it had to do was process sound then i think the frame rate would even tripple if not...more.

ill write an include file anyways and people can try it out and let me know if it works well or not.

if i offered you cash would you be willing to program the midi save feature to this program? Or add a more simple command in your plugin to save midi files?

How much would it take

I love music and id love to see this program have all the potential thats possible.

let me know

if you do write a new command in the dll maby you can make a set tempo as well? A command to check and see if its time to go to the next notes.
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd May 2008 04:25
Oh do you have a logo? Let me flash it at the start of my program too
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd May 2008 18:21 Edited at: 3rd May 2008 18:23
Well, I've been looking into this for a while now; it seems to be more complex than you would think, given the annoying variable lenght of the time stamps. Also, the messages are read from right to left (which is not the case with the midi api), so it takes a while to get used to...

Anyhow, I think that I'm starting to make progress on this now, as I've finally managed to programatically create a midi file that will actually run.

I'm working as fast as I can on this, but you should be aware that this is my final year in high-school which is coming to its end, so there's quite a lot of schoolwork for me to do as well.

How much would you be willing to donate to my tuxedo for this job? (I'm planning a midi export function and maybe, if I figure it out, a way to directly load a Qmidi song as a music file in DBPro).

Cheers,
Rudolpho.

Edit: I actually have the 3d artist of my team working on a logo theese days. It will be a pretty hilarious one, but perhaps it would be fun if you could include it still so.

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd May 2008 22:44 Edited at: 3rd May 2008 22:44
Yup! I will gladly Pay you some cash if we can some how get something good to work with dbpro....if its midi file playback or another dll that will crunch all the music data in to play without killing the framerate.

I work full time as a Petrolium-Tech but i always try to find time to do some coding

What would you like to try doing...include qmidi playback within your midi plugin or try to give me a quick reference to saving as a midi file?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd May 2008 23:41 Edited at: 4th May 2008 01:12
Well, I'm currently working on a way of converting a .qmd file to a midi file. I was thinking that I'd put this command in a stand-alone plugin that you could use in your editor.

It would work something like
.

Do x in the music array exist only for actual note events or is it there on every single 1/16:th portion, so that it can be used for determinig the times when the notes are to be triggered?

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th May 2008 05:58
ya x is every 16th of a note playing forward

(1 note space) for the editor

and it plays until it hits the last note marker
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th May 2008 07:53
oh i should give you my new compressed format *.qmo



This is the way it writes the music data now. And the result....Way smaller file sizes try saving your song with that extension
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th May 2008 23:03
Ok, so you changed the format...
Well, luckily enough, this isn't that different.

What's the qq variable for though; as far as I can see, you could just remove it and save some more bytes?

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th May 2008 23:47
qq is check if there is more data to load
if qq=0 then more data to load
if qq=1 then it is finished loading



it makes the files way smaller
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th May 2008 23:49
i do see another way to save on bytes even more i suppose.....
but i will keep it like this since its already very small file sizes
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th May 2008 18:01
Just to check, this is the music data format, right?


Cheers

"I kören hörs de brummande busarna Björnligan och Gondolen"
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th May 2008 23:06 Edited at: 5th May 2008 23:08
Allright, just to let you know, I've made some progress over the last days.
I've got a working function collection to ease the further work and I've made a subroutine to determine the expected chunk sizes. After tedious error checks in my 800 lines test project, I've actually even managed to get it to create runable midi files.

So basically, what's left to be done would be to get your file data converted to a workable stream and some optimization, which will probably become neccessary during the process.

I've attached a... um... well, it's not directly musical, but it is done entirely using the functions I've come up with the last days.

"I kören hörs de brummande busarna Björnligan och Gondolen"

Attachments

Login to view attachments
Nemesis_0_
20
Years of Service
User Offline
Joined: 26th Dec 2003
Location: Canada
Posted: 15th May 2008 00:50
mad mad MAAAAD PROPS man

SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 16th May 2008 03:36
Nice

If i keep adding new features its gunna keep getting worse to figure out...lol

Now that it has pitch bending being used too as well as octave settings
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 16th May 2008 03:40
im going to make a quick player in dbpro for you to see exactly how it all works
For loading the qmo file format

give me a few mins to post it......and you will need your own plugin installed....duh! lol
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 16th May 2008 04:35
Here is the example for the latest format vr 4

it has dbpro example and does not require any other dlls to work other than yours...

did this help?

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th May 2008 17:12
Allright.... I don't know what "props" is, but I'm going to assume that it's not an insult... (short for properties, mayhap?)

Yet a new format, huh?
Well, I'll look into it.
The main problem as of current is the 7-bit values.... I've got to refine some of my old math skills as towards rest (if that what's it called in english). It should basically just be a matter of rewriting 256 integer parts to 127 integer parts, but still so, it seems to take its sweet time....

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 16th May 2008 19:02
the only diff in this format was to include octaves and pitch changes

i wont make any more i promiss....lol

unless it makes it better.......
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 27th Jul 2008 21:51
Update
The midiIn portion has been updated slightly.
Previously, certain midiIn messages that were intercepted during the processing time between checking the amount of items in the buffer and purging it would normally not get handled and could as of thus easily cause stuck notes, etc.

This is now possible to avoid to a greater extent due to an extra overloaded clear midiIn buffer command.
By specifying how many messages that you have actually processed from the midi buffer since last purging it, the plugin will check if there are any remaining notes after that index in the buffer, in such an event move this to the beginning of ot and then wipe the rest. In this way, any missed messages will simply be handled in the next loop cycle.
While I haven't tested this very thoroughly yet, it at least seems to be a great improvement, if it doesn't solve the problem completely.

The clear midiIn buffer command can also, optionally, return how many messages beside the ones you've checked that remains.

The updated download is attached to this post.

"I kören hörs de brummande busarna Björnligan och Gondolen"

Attachments

Login to view attachments
BlobVanDam
15
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 29th Jul 2008 18:12
Thanks for working further on this plugin Rudolpho! It's been a great help.
The update has significantly decreased the amount of MIDI messages that get missed.
I still get the occasional message slipping through. I hope you still find it worthwhile to find a way to fix it entirely somehow. Do you know why/how it can still manage to miss the occasional MIDI message when you're only clearing the messages you've accounted for?
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Aug 2008 00:54 Edited at: 4th Aug 2008 00:56
One would think that it shouldn't take any considerable time, but it might still be that the new message is received in the (very brief) moment when the purge function is called and the plugin function is clearing the buffer. If that happens, it won't get accounted for.
I also have a verification check to see that all arrays etc. are set up properly before running most functions in the plugin. Removing this check from the purging function might save an extremely short amount of time, however - should the user then attempt to call this function without a previous call to init midi plugin, the host application would likely crash.

I'll look into this in a short while; I'm currently adding a simple parsing interface (so that you can get the type, value, etc. of single midi messages easily).
Thanks for letting me know

"I kören hörs de brummande busarna Björnligan och Gondolen"
BlobVanDam
15
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 4th Aug 2008 10:04
Well you see, your midi plugin is critical to the work I am currently doing.

I would think you are right about where the midi messages are still being missed. I didn't find a way to eliminate the problem in DBP at all, so I believe that any tiny delay in DBP is causing the same problem every time. The solution might be to offload more of the midi work to the plugin rather than let the user handle it, where DB might be causing some delays.

I can't wait to see the new changes! Good luck with it all, and you know you've always got one huge fan of your plugin right here.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Aug 2008 20:58 Edited at: 5th Aug 2008 21:07
Well, no, whatever delays are due to your program don't have anything to do with it; the midiIn buffer is filled through a callback routine that is called everytime a new message arrives, so the problem is most certainly caused by a message happening to arrive at the exact moment while the buffer purging is ongoing.
(This is the only time that the midiMsgs variable, which is responsible for holding how many items are in the buffer, is changed).

I think that I have worked out a satisfactory solution for that by now however; see the new update in my next post.

And thanks for the appreciation once again

"I kören hörs de brummande busarna Björnligan och Gondolen"
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Aug 2008 20:58 Edited at: 6th Aug 2008 20:28
Update - midi message parsing and proper midiIn (at last)

I've revisited this project during the last few days, trying to improve what was alredy there, as well as adding some new features.
I must say that I'm pleased with the results - midiIn now seems to work flawless (I managed to play at high speed for at least ten minutes or so, without any missed messages. The same goes for patching a full orchestral arrangement (as shown in the screenshot). If you want to try and press it further to determine whether it is in fact waterproof, you're welcome ).

So, here's a list of the most important updates:

Far superior midiIn handling. I haven't missed one single message in hours of testing.
The new buffer handling also gives you a few extra bytes less memory usage, but that's far from noticable for the regular user.

Midi message "parsing" system. This let's you easily extract information from any midi message, returning it's type, channel of affection, notes, levels, etc. This is a great asset for applications that make use of the midiIn functions.

An include file containing constant declarations for the various midi message types, to go with the parsing commands.
You will also find that I have been generous enough to put an array in this include file as well, containing the standard names for all 128 general midi bank instruments.

New documentation files for the new commands as well as a few fixes to the old ones.

I've fixed a bug with OPEN MIDIOUT PORT.
Apparently, the port opened was one index lower than the one supplied. Note that this means that, have you already got something working with this command and get the new plugin, you will need to increase the number of any port you open by a value of one.


I have also written a small demonstration application, which you can download with the full source code here.
Notice that my gui functions are pretty messy. I haven't tidied them up either, so you might well find unused references and outcommented lines there. That is unimportant here however, since the purpose was to demonstrate the midi plugin, and not my interface building capabilities. Also, bear in mind that I wrote this using only DBPro's core commands, for maximized compability.

Here's a screenshot of the demo application

As you can see, I couldn't think of any fitting name, so I did like any trusty member of the TGC community and just took the most descriptive word I could think of (midi) and slapped it in after 'Dark'.

So, go ahead, try it out and let me know what you think, or if there are any remaining problems, etc.

(The plugin update is attached to this post).

"I kören hörs de brummande busarna Björnligan och Gondolen"

Attachments

Login to view attachments
BlobVanDam
15
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 6th Aug 2008 09:13
WOW! This is fantastic! You have honestly made my day.
I've had a small test with it and it's been flawless so far. I've spent most of my time so far changing my code to use the new parsing system, which is so much neater and easier to work with than what I was doing previously. And it adds the ease of use without sacrificing any power either. It's nice to have all of those constants for the controller types, yet I can still take the values and dump them straight into an array like I have been doing. It's so much easier to work with the midi data now.

Just a bit of info for you, the NoteOn message (0x9) can also act as a NoteOff command when it sends a velocity value of 0, in case you didn't already know.
I assume 0x8 is probably the more common, but my particular keyboard does it the alternate way, so just letting you know for compatibility when coding your programs like your demo. It only takes a few more lines to make it compatible with both.

I think it's fair to say you have now created the perfect definitive MidiIn plugin for DBP. I can't thank you enough
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 6th Aug 2008 20:38
I'm glad it's working for you
I'm looking forward to see that program of yours, once it's finished

About the noteOn message, I actually did know that, but still I didn't think of it... oh well, I've updated the plugin to take care of that - just redownload it. What it does now is to send you a noteOff type, even when the received message predicts a noteOn - velocity 0 event.

Quote: "I think it's fair to say you have now created the perfect definitive MidiIn plugin for DBP. I can't thank you enough "

Haha, thanks
It's a bit sad that not a great many DBPro'ers care to much about midi though.
(Be creative folks! That old dusty sustain pedal can be used as a gas pedal in your next racing game!)

"I kören hörs de brummande busarna Björnligan och Gondolen"
BlobVanDam
15
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 9th Aug 2008 19:39
Well after using this non stop since you updated it, I haven't had a single midi message slip
Shame the rest of this program I'm making isn't as pain-free to work with as your plugin
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Sep 2008 22:06
Sounds good. I have had it working all the time as well, so I guess that it's pretty much stable by now

(I didn't see your last message until now; for some reason the board system won't state that a user on probation has posted to a thread..)

"I kören hörs de brummande busarna Björnligan och Gondolen"
calcyman
16
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 11th Oct 2008 12:52
I've downloaded your plugin to find that the example app returns an "Array Subscript out of bounds" error.

The optomist's right, The pessimist's right.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Oct 2008 15:07 Edited at: 12th Oct 2008 15:09
Yeah, like I just said to another guy - if you don't have any midi ports / devices on your system, this won't work.
Try downloading LoopBe1 internal midi (google) and try again.

(Maybe I should have added an error message saying that you don't have any devices though).

"I kören hörs de brummande busarna Björnligan och Gondolen"
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Nov 2008 21:19
So, I was thinking about maybe adding a means of posting messages directly to the internal midiIn buffer (which would be useful if you make a program that can either output to an external midi device or process incoming messages); would anybody find such functionality useful?


-> Oh, come on...
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 2nd Feb 2009 01:46 Edited at: 2nd Feb 2009 01:51
Hey there seems to be a huge slow down from the last version i had to your newest one released.

looks to be a midi off note slow down

my music program jumped from 67 fps to 3 the second i switched over to your new plugin.
I isolated the bad slow down to that command.... seems calling it a tun of times in one loop has dropped the frame rate big time from your last version...

i down graded to your old release and im back up to 67 fps


for example:
for x=1 to 60
for t=1 to 10
midi note off #,t,x
next t
next x

calling all that in one sync distroys my frame rate from 67 to 3

with the old plugin i can keep that code in there and have 67 fps

SMD3DInteractive
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Feb 2009 20:14
Granted, it takes a while to run that section; I get around 28 FPS when doing nothing else but this:


However, all the similar commands (midi note on, set channel volume, etc.) run at approximately that time. Are you certain that this did go faster in an earlier version, for I haven't changed those functions for more than a year, I think? Could you perhaps send me the faster plugin?

Also, you might want to try out the turn all channel voices off command for that kind of use. Moreover, why would you need to run that section more than once in a while; certainly, it can't be neccessary to have in your main loop?

"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd Feb 2009 01:40 Edited at: 3rd Feb 2009 01:43
Here is the version that runs at much higher frame rate.....it is possible that it was the midiin buffer that slowed things down.....but it seamed if i isolated a chunk of code that turned all the notes off that shouldnt be on ....made it go alot faster..

3fps vrs 67fps

Quote: "why is it nessesary to run that in each loop"

To ensure there is no notes sticking on for some sound cards ive been testing need a note off called twice to make sure it shuts it off. By calling it every loop just made it work fine with no frame rate loss.

here is the fast plugin

SMD3DInteractive

Attachments

Login to view attachments
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 3rd Feb 2009 01:50
Also here is the latest screen shot of single track editing:

SMD3DInteractive

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Feb 2009 10:11
Hm, that's odd - I find that both versions run at exactly the same speed with this small test code; can you verify that it does / doesn't for you as well?


Running that showed me that my machine is capable of calling that command around 60 000 times per second.


Quote: "To ensure there is no notes sticking on for some sound cards ive been testing need a note off called twice to make sure it shuts it off. By calling it every loop just made it work fine with no frame rate loss."

Well, but then you cannot use it during playback, or else you would get no tones whatsoever, right?
So, I'm guessing this only needs to be done when exiting the playback mode. If some devices won't respond to a single note off event (I don't know why they wouldn't... maybe that very note has been "turned on twice earlier?), you could just run a few iterations of that loop after exiting the playback loop, I think?

Again, I myself see no speed changes between the earlier and current plugin version, so it seems very odd. About the midiIn buffer, it runs in its own (callback) thread, so it shouldn't really affect the speed of the main application.

"We know some things about poodles, for example that they are alive, they can bark, they eat meat..."
- Extract from Objects first with Java.
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 5th Feb 2009 16:42
looks like there is no difference in that code

i get: .021 sec on new one and .020 sec on old one.

Im thinking it had something to do with the midi in buffer after all. But i will run some tests again when i get to that point.

I thought it was just strange that my fps dipped from 67 to 3.... but im sure a good part of it is just in my code...

SMD3DInteractive

Login to post a reply

Server time is: 2024-03-29 04:57:30
Your offset time is: 2024-03-29 04:57:30