Midi out plugin and music reading trainer - need advice.

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

Post Reply
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Midi out plugin and music reading trainer - need advice.

Post by StevenM »

I'm working on a music sight reading trainer for 25 key input devices.
I'll share DLL extention after I add some more functions.

So far:

Code: Select all

int GetNumMidiDevices(){}
int OpenDevice(int devnum){}
int SendNoteOn(int Chn,int Note,int Vel){}
int SendNoteOff(int Chn,int Note){}
void closedevice(){}
void writeDeviceNames(int devcount){}
int DeviceListExist(){}
I'm having a bit of difficulty here though. first, I could not pass strings with function calls. The reason for this makes sense so -

As a work around to get the midi device names

"writeDeviceNames" creates a a text file in the project directory. this "DeviceListExist()" makes sure the text file was created.

The text file get's named: "devnames.txt"

Code: Select all

"0$Microsoft GS Wavetable Synth$"
"1$Maple Midi Out: Port 1$"
"2$Maple Midi Out: Port 2$"
"3$Maple Midi Out: Port 3$"
"4$Maple Midi Out: Port 4$"
"5$LPK25$"
"6$nanoKONTROL$"
"]"

I've spent a way too much time trying to parse this though. If anyone can give me some tips it would be appreciated. All I want to do is read the file and create a user selection menu for it.

snap shot of the project -
Attachments
SightReading Trainer.jpg
SightReading Trainer.jpg (281.82 KiB) Viewed 12671 times
User avatar
VilleK
Site Admin
Posts: 2251
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hi Steven. What happens when you try to return a string from your dll? It should work. In this thread Kjell calls a OpenGL exported function that returns a string.

If you want to return a list of strings, just do something like this and return one string at a time:
int getDeviceCount()
string getDeviceName(int nr)
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

It would make things a lot better -I'm using freebasic to create the DLL - I get a pointer value instead of a string.

I found this info:

Note: When passing Strings as parameters to Subs, they should always be passed by reference (ByRef). Currently, ByVal does not pass a copy of the string, but a Pointer to the string data. This can cause unexpected behavior.

I'll try byRef, and let you know if it works.

EDIT: there seems to be some issue mentioned here too:
http://www.freebasic.net/forum/viewtopi ... ole+string

BSTR Data type??

I can't seem to find a way to make it work.
User avatar
VilleK
Site Admin
Posts: 2251
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

"ZString Ptr" looks like a good datatype to use in FB. Strings in ZGE are zero-terminated ansi 8-bit strings and should be compatible with that format. I just took a quick glance at the FB documentation though, so I cannot be sure.
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

ByRef didn't work - Here is a simple DLL, zproj, and basic code. I can call the function but the string that is passed is mangled.

Edit: removed the attached file problem resolved below.
Last edited by StevenM on Mon Jun 20, 2011 8:43 am, edited 1 time in total.
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

ZString Ptr - I'll look at that thanks Ville!
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

Your amazing Ville - thanks - Zstring Ptr works fine.
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

Here is a simple zproj, basic, and DLL for zstring ptr.

I never use pointers - is it ok to implement it just like this?
Attachments
ZstringPTrSample.zip
(5.06 KiB) Downloaded 549 times
StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM »

just added it and tested it -

writeDeviceNames(int devID){} as you sugested - to read each device.

It's working good - Thanks again. Now I have to undo all my sloppy work arounds :oops: I'm asking sooner in the future.
Post Reply