Jump to content

creating a buffer of all ON notes


levon
 Share

Recommended Posts

Hi, have had a search and cant find anything similar to this.

so heres what i want to do.

have a Midi keyboard plugged into my Midibox. the midi box monitors the incoming notes. when a button is pressed on the midibox, it stores all notes into an array. but it needs to take into account the buttons that have been let go. Im thinking, if i have an array, with 128 bytes in each, each address number is the same as the midi note number it references. ie, note 00 is in Midi_Buffer[0] and note 24 in Midi_Buffer[24] etc. then when a midi note ON is received, it stores it in the array address, and midi note OFF deletes it. just wanted to share my idea, and see if anyone had any other ideas.

,Levon

Link to comment
Share on other sites

Hey Stryd, sorry for got to mention your idea, but ive been expanding on it. stryd suggested that i have one array that records the midi on notes, and another that records the midi off notes, then compares the two.

Nils, im making a sort of sustain pedal. so it will play each note that is stored once another button is pressed.

ok, n00b question, im fairly new to C, but have used python in the past.

when im trying to write to the array, but i get an error message on compile.

im defining it at the start with

const unsigned char midi_buffer[128];
and on this line
 midi_buffer[evnt0] = evnt0;

it has the error message "error: assignment of read-only location"

How do i write to an entry in the array? ive searched the net for C tutorials and they write an entry to an array this way.

thanks, Levon

Link to comment
Share on other sites

when im trying to write to the array, but i get an error message on compile.

im defining it at the start with

const unsigned char midi_buffer[128];
and on this line
 midi_buffer[evnt0] = evnt0;

it has the error message "error: assignment of read-only location"

How do i write to an entry in the array? ive searched the net for C tutorials and they write an entry to an array this way.

The const keyword means constant! So yes you try to write in a read-only location :)

Best regards, Didier.

Link to comment
Share on other sites

Hey Stryd, sorry for got to mention your idea, but ive been expanding on it.

Actually this is totally different :) This way will be easier on the CPU but is way memory heavy in comparison. There were a few other tips I gave you regarding the timing of the other method, so that the core is doing work when it's not timing specific, that should overcome any problems though. This way will be way easier to code though, so go with this unless you need more RAM later :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...