Testing midi Input Problems

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

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

Testing midi Input Problems

Postby StevenM » Fri Jan 21, 2011 8:37 pm

I am hoping that someone can help me solve a couple problems that I am having with this midi input test.

The test is simple - 24 cubes that change color when a midi note event is sent. the keys are C4-B5.

When a note is pressed a cube changes color - on release the cube goes back to it's previous color.

2 problems - one is that pressing a note twice in a row does not work (I have no idea why)

Another is chords - more than one note at a time is not working - some advise to get those things working would be really appreciated.

Edit: I Knew chords were going to be a problem. I'll probably have to store the note-on events for chords in an array to make it work, but I'm just not sure of the best way to go about it.
Attachments
MidiTest01.zgeproj
Midi In Testing project - some problems.
(25.4 KiB) Downloaded 220 times

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

Postby StevenM » Fri Jan 21, 2011 11:08 pm

I think I figured it out. I'll upload a new test project later.

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Fri Jan 21, 2011 11:16 pm

Just had a quick look and one thing you should think of that I didn't made clear in the documentation is that OnMidiMessage can be called several times in a row between frames. A chord will trigger a burst of messages which means your OnUpdate and OnRender code won't be called after each separate midi command, so you will need to design your effect with that in mind.

There could also be problems with my implementation so let me know if it keeps behaving strangely.

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

Postby StevenM » Sat Jan 22, 2011 12:02 am

Yes, it's good though - all the data is there - I found a solution, seems to work well, I'm just passing the bursts on to an array with every status change.

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

Postby StevenM » Sat Jan 22, 2011 12:52 am

This works...but maybe there is a better more efficient way? It's pretty fast and responds well enough though. Chords work for the most part on-off is working ok. I can still make it glitch, but I think I can get it to work better. The code is really messy.

Edit:

Works ok, from my keyboard - on-off events are not working from the piano roll. I'm missing something with on-off events. seems like the piano roll doesn't always send an off event.

I'll fix this tommorow.
Attachments
MidiTest01.zgeproj
(29.44 KiB) Downloaded 216 times

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

Postby StevenM » Sat Jan 22, 2011 12:31 pm

Just checked with Gol - the piano roll does send midi off, but if there is not a at least a 1/4 step gap between the notes then my test project misses it. I think it is just be the way I implemented things.

I'm going to start over and see if I can improve the response time. with a different approach. I seem to have a better idea about how the midi data is streaming in now.

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Sat Jan 22, 2011 9:19 pm

Try to do the action you want (setting the note colors) directly in OnMidiMessage instead of buffering and waiting to OnUpdate.

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

Postby StevenM » Sat Jan 22, 2011 10:52 pm

This is working for me. I took a different approach here. I made that Status,data1,data2 events Global arrays - instead of passing all those variables. Much easier not to difficult to work with either.

Edit: The midi off problem is resolved too.
Attachments
MidiTest01.zgeproj
(19.47 KiB) Downloaded 242 times
Last edited by StevenM on Sun Jan 23, 2011 5:35 am, edited 1 time in total.

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

Postby StevenM » Sun Jan 23, 2011 12:40 am

I uploaded a video test here: http://www.youtube.com/watch?v=WPRiSXcr4kA - it is working well. I really stressed things and it is keeping up just fine. I'm going to start working on some more interesting projects. I'm sure the project code can be tweaked to be better, but this is good for most anything I plan on doing so far.

Same preset with feedback applied(I had to use a custom feedback preset)

Midi test - testing note response time, fast notes, fast tempo, chords. It's seem to be working well with no glitches. nothing elborate - just a bunch "random" playing on synth.

Midi out can be layered with a synth to get live visual feedback too - it's incredible - there really is not anything quite like it out there.

User avatar
VilleK
Site Admin
Posts: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Sun Jan 23, 2011 10:25 am

I'm glad it works! Hopefully we can add features to make it easier to debug effects later, such as a visible log-window inside ZgeViz.

About your effects you could simplify your code by using an array with datatype Model and creating the entries something like this:

Code: Select all

for(int i = 0; i<10; i++) {
  model m = createModel(NoteModel);
  m.Position.X = i;
  m.IsNoteOn = 0;  //IsNoteOn is a DefineVariable located in NoteModel.Definitions
  TheArray[I] = m;  //TheArray is a DefineArray of type Model
}


That way you could also use a singe Mesh defined with a MeshBox and just move it to different positions. In Model.OnRender you would have an expression that tests the IsNoteOn-variable and set the color accordingly using a RenderColor component.

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

Postby StevenM » Sun Jan 23, 2011 12:51 pm

VilleK wrote:I'm glad it works! Hopefully we can add features to make it easier to debug effects later, such as a visible log-window inside ZgeViz.

About your effects you could simplify your code by using an array with datatype Model and creating the entries something like this:

Code: Select all

for(int i = 0; i<10; i++) {
  model m = createModel(NoteModel);
  m.Position.X = i;
  m.IsNoteOn = 0;  //IsNoteOn is a DefineVariable located in NoteModel.Definitions
  TheArray[I] = m;  //TheArray is a DefineArray of type Model
}



That way you could also use a singe Mesh defined with a MeshBox and just move it to different positions. In Model.OnRender you would have an expression that tests the IsNoteOn-variable and set the color accordingly using a RenderColor component.



Yes, I was thinking of doing it that way. In fact, for an entire keyboard it would probably be essential. I was a little uncertain about "createModel", because I wanted to use a "by reference" duplication. If I clone- would it require me to update(redraw) all the meshes for every frame, instead of just changing a property for a specific cube?

Edit: I didn't know about this,

TheArray[I] = m; //TheArray is a DefineArray of type Model

I'll have to try it.

There is still so much I have yet to learn. It's going to take a while for me to get up to speed, one step at a time. Tips and Tricks are extremely helpful. Some of the work I've seen here is just mind boggling (jph, kjell)
Last edited by StevenM on Sun Jan 23, 2011 2:31 pm, edited 3 times in total.

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

Postby StevenM » Sun Jan 23, 2011 1:23 pm

Hopefully we can add features to make it easier to debug effects later, such as a visible log-window inside ZgeViz.


That would be good - anything that makes development easier would be great. Also testing projects in FL Studio can have some disastrous consequences with certain errors messages.

Some errors create many repeated error message windows in FL Studio. I encountered this with this test project,(array out of bounds error). Can you check to see if there is a way to prevent that? When it happens - I need to open the task manager to close FL Studio and restart.

If you havn't seen this before, just create a bad array and load it into ZGEviz. (warning) it looks scary though, I try to close it as fast as I can with the task manager.


Return to “ZGameEditor Visualizer”

Who is online

Users browsing this forum: No registered users and 2 guests