Reputation: 3476
Just as a toy, I'm using the iTunes SDK and XNA to make my own quasi-GuitarHero game. The actual libraries aren't important, so I didn't tag them. This question is about a data structure.
Basically I want to start playing a song, and allow the user to play guitar to the song, recording in memory the Red/Yellow/Green/Blue/Orange key presses, as well as the strum, to play back later.
I've tried several different techniques, the most accurate being a bitwise int[]
array where each element represents a 10ms time slot (and each bit of each int represents a physical key) once as an offset from the song start. This seems inefficient however, as I have to pigeonhole keypresses into these 10ms slots, not to mention a huge array size for a several minute song.
Any suggestions for a better way to implement this? My goal is to then serialize this data structure to disk for retrieval later. The overall goal of this project is to use this data to control LEDs in some fashion to a song, FWIW.
Thanks!
Upvotes: 0
Views: 111
Reputation: 838226
I would store the key up and key down events in a log format with a timestamp (relative to the start of the file) at the appropriate precision. You could use a List together with a custom class for storing details of the event type (which key, and up or down) and the timestamp.
Upvotes: 1