Shop OBEX P1 Docs P2 Docs Learn Events
Piano Practice Timer...using MIDI? — Parallax Forums

Piano Practice Timer...using MIDI?

My daughter practices piano 30 minutes a day. She's really good at piano, has won awards for songwriting, etc. But an eight year old can get a little distracted sometimes. In 30 minutes of practice, there is quite a bit of page turning and other stalling behaviors that are just burning time on the timer.

So I got an app that listens and stops the clock when there is not playing. But she realizes if she sings or talks, the app will continue to count down. Little sneaky kid!

So I want to use a Basic Stamp to monitor the MIDI output (on this keyboard, MIDI goes out via USB). I want it to count down when she is playing, but stop the countdown if a note has not been pushed in X seconds.

Yes I know, she could fool this as well. I mainly want to do this just to see if it can be done.

Any ideas?

Comments

  • ElectrodudeElectrodude Posts: 1,660
    edited 2015-10-26 20:39
    Every time you receive a note down event, increment a counter. Every time you get a note up, decrement the counter. Whenever the counter is non-zero (i.e. a non-zero number of keys are down), decrement the timer. That way, you won't need to track which keys are down.

    That might not work - I think I remember at least one device that kept repeatedly sending $9x (note on) if you held a note down. I haven't used MIDI in a while, though, and it might have actually been sending $Ax (aftertouch), which seems more likely now that I think about it.

    The main problem with using a Basic Stamp is that it can't really accurately measure time without an external RTC chip. SERIN has a timeout command, but I don't think there's any way to get how much time was left when the timeout happens.

    I would go with an RTC chip. You'd only get one second granularity, but that would probably be perfect for music, since songs have rests where no notes are held down but where the song is still technically actively being played.
  • JonnyMacJonnyMac Posts: 9,157
    edited 2015-10-26 23:40
    A Propeller would be better suited for this project. You can cleanly RX a MIDI stream in one cog while running a timer in another. I have a little timer object that I use for count-up and count-down timing, and it has hold() and release() methods -- these would be helpful in your app.

    I just caught the bit about MIDI over USB; neither the Propeller nor the BASIC Stamp can be a USB master (which is what your keyboard expects). It doesn't have a traditional 5-pin MIDI connector too? If yes, you can connect to a micro.
  • The MIDI-over-USB thing might not be a problem. If you're just looking for MIDI activity, it may only be necessary to monitor the USB's D+ or D- line for transitions. This is premised, of course, on the assumption that activity on these lines happens only when data are being transferred. That may not, in fact, be the case.

    -Phil
  • ercoerco Posts: 20,257
    Somebody elsewhere came up with a clever way to measure NiMH battery capacity using a dollar quartz analog clock movement. They have a separate circuit to drain the battery at fairly constant current, and the clock is powered directly by the NiMH cell under load. "Zero" the clock hands at 12 noon to start the test. The movement stops working at 0.9-1.0V, right at the cutoff voltage for a NiMH. Then just read the hours & minutes of runtime (ergo capacity, WRT drain current) by looking at the stopped hands.

    This nifty solution made me think about other ways to use cheap analog clock movements. The problem at hand might use one to good effect. Any output from MIDI or even audio out (re)triggers a 555 timer one-shot which turns the clock on for a second or two through a transistor.

    Be sure to put the clock behind clear plastic or somewhere your daughter can't manually push the hands forward!
Sign In or Register to comment.