User's constant input keeps a song going.
May 27, 2011 8:30 PM   Subscribe

As long as the user, say, presses a key on his/her keyboard in sync with, say, a flashing light onscreen, a sound file will continue to play. If he/she stops pressing the key, the song stops until the in-sync keying resumes. Can I get/program/build this?

I'm fairly open to as to platform (e.g., website, phone app, standalone gadget), the action required by the user (key press, mouse click, voice activation), and the sync cue (flashing light, metronome, whatever), but I'd like to find something that requires a fairly constant action by the user in order to continue to hear a song.

The goal isn't so much to test the user's skill as to require a continuing affirmation that he/she wants the song to keep playing. I suppose for simplicity's sake it would make sense for the sync cue to fall on the beat (though not necessarily every beat) of the song, but again, it's more important that the user keeps affirming, so their accuracy isn't important either. As long as their experience is "Hey, I make this song keep playing." Kind of like a really, really simple and forgiving variation of the principle behind Guitar Hero or Rock Band.

What hardware, software, and/or programming language could accomplish such a task? I'm interested in as many varieties of this idea as people can come up with, so the more the merrier.
posted by Rykey to Computers & Internet (5 answers total)
 
That would be very easy to do in Flash.
posted by Chocolate Pickle at 8:38 PM on May 27, 2011


What hardware, software, and/or programming language could accomplish such a task?

I think a better question would be what hardware, software and/or programming language couldn't accomplish such a task. As Chocolate Pickle says it would be very easy to do in Flash but it should be pretty easy in any programmable environment capable of playing sound and accepting input. I could write something in C using Allegro to do this, for example, although that wouldn't be ideal. I imagine it would be simple to do with a game creation program like GameMaker.

The only real issue I can think of would be whether the program would need to be able to play any arbitrary sound file (of a particular format), or only sound files that it is set up to play. If the former, you wouldn't be able to make sure that the cue falls on the beat unless you had some way of analysing the music to find the beat. I think this is possible but likely to fail on more complex pieces.
posted by A Thousand Baited Hooks at 8:53 PM on May 27, 2011


I think there are also stylistic differences— you need to know what kind of music it is in order to extract the beat in the same way a listener would.

If you don't require the user to press the key on the beat, but just kinda sorta in time with the music, everything's easier.
posted by hattifattener at 10:12 PM on May 27, 2011


Response by poster: Yeah, it's probably pretty clear that I don't know much about programming. Thanks for the suggestions.

To clarify-- I want to use an actual song file of fairly high quality since part of my purpose would be to show off the actual music (mp3 tracks from an album I recorded). The user wouldn't have to press keys right on the beat-- as hattifattener says, just "kinda sorta" in time. But the application's reaction to the user stopping for more than a few seconds would need to be pretty responsive-- the less lag in pausing the song the better.

Can anyone point me to either examples of what I'm talking about on the web (specifically with an audio file), or (besides GameMaker, thanks A Thousand Baited Hooks) tell me what kind of software can most easily build such an app for a beginner? Or am I better off hiring a programmer to make this for me?
posted by Rykey at 4:53 AM on May 28, 2011


Depends on how "kinda sorta" you want. For example, here's some psuedocode

timeSinceKeyHit = 0
audioFile.startPlaying

(start timeSinceKeyHit counter, incrementing 1 every second)

onEvent(KeyHit){set timeSinceKeyHit = 0}

if timeSinceKeyHit > 3 then audioFile.stopPlaying


Not functional but that's about all you need to get it going—something that would be fun to learn as a beginner in Processing, BUT it has no beat detection and basically just a dumb switch that is constantly told to not fire.

To sync up the timer with the beat is considerably tougher. If you know the beat of the song you can set the timer to be that length—but what if the audio doesn't play instantly each time? You'd basically be sending out two troops with no way of communicating—but it might be close enough for your purposes.
posted by Brainy at 11:03 AM on May 31, 2011


« Older Writing against one's own inclinations   |   Please help me with audio as if I'm a n00b. Newer »
This thread is closed to new comments.