Hi everyone, hoping to get opinions from gurus on here, who have been *incredibly* helpful in getting my project to where its at. A million thank yous!<div><br></div><div>Ok, the situation so far, which is working well:</div>
<div>- the app uses a generalized 'message' structure, all the different forms of messages fit into this structure by having it act alike a union. ( ie, a message always takes up the same amount of space, no matter the type )</div>
<div>- messages do not container pointers, in order that they be simple to send and receive over network clients, hardware, etc</div><div>- there are ringbuffers between my audio thread and real time thread</div><div><br>
</div><div>What I'm tackling:</div><div>- I want to add the capability for messages to have deferred execution, so they can be sent with a 'process at 4:3:1' kind of thing</div><div>- I think the best tradeoff for my app so far will be to use a hybrid of a timeline array and a linked list. there will be coarse time values stored by raw array indexing, speeding up lookup, and fine time values will be stored in the messages themselves</div>
<div>- so, when the engine is processing deferred messages, it will go and check timelineArray for all messages at bar 1:beat 1, which will be a linked list of all the messages with start time between bar:1 beat 1 and bar 1: beat 2 ( time resolution may change, this just for example</div>
<div>- then the engine iterates on every tick through that list of messages. This way, iteration on every tick is limited to a reasonable sized linked list and I can play with the cpu vs data storage equation by simply changing the resolution of the time line array</div>
<div><br></div><div>Issues:</div><div>- I need to allocate memory for new linked list items in the realtime thread</div><div>- the timeline array needs to be able to grow in the real time thread</div><div><br></div><div>Thoughts:</div>
<div>- I don't need to get it perfect *right now* but I need to be able to change it to Really Good later</div><div>- I checked out some resources, like this one the <span class="Apple-style-span" style="font-size:15px;font-weight:bold"><a href="http://www.google.ca/url?sa=t&rct=j&q=audio%20allocating%20memory%20in%20real%20time%20thread&source=web&cd=3&ved=0CDIQFjAC&url=http%3A%2F%2Fwww.cs.cmu.edu%2F%7Erbd%2Fdoc%2Ficmc2005workshop%2Freal-time-systems-concepts-design-patterns.pdf&ei=g1xJT66mEYvOiALDnN3oAQ&usg=AFQjCNET-FI8lrlYfnIBP39Dwr-GLDptrA&sig2=f5fUXFebwZ6MpOcF2tYJug&cad=rja" class="l">Design Patterns for <em>Real</em>-<em>Time</em> Computer <em>Music</em> Systems</a></span></div>
<div>and the supercollider book chapter and see there are a lot of options</div><div>- I could pre-allocate a giant list of messages and pluck the data off that list when I need to make a new one</div><div>- I could pre-allocate a block of memory and allocate off that</div>
<div>- I could allocate in the non-realtime thread and then pass memory over in queues. </div><div><br></div><div>Would love to hear opinions on how others would solve these, including tradeoffs of each.</div><div><br></div>
<div>thanks!</div><div>iain</div>