Using barcode scanner data for audio/MIDI

    MaxMSP

    seejayjames's icon
    seejayjames's icon
    seejayjames
    Mar 10 2023 | 7:46 pm
    Hello everyone! Been a long time. Great to see how far Max has progressed!
    I’m interested in using barcode scanners to generate audio/MIDI/etc and am wondering what others have found in this area. Seen a few interesting videos with a Japanese group doing this, but it seems like the scanners have been modified, which I’d like to avoid---just use what they naturally output and let Max do the rest.
    From what I’ve read, most scanners send a numeric text string as keystrokes, so it should be pretty simple to get access via [key] or other text objects. That’s OK to get single strings of unique numbers to play back samples etc. But I’d like to make it more of an instrument versus a sample trigger. Specifically:
    -- Long unique numbers aren’t needed. Rather, I’d like a smaller set of simpler numbers that I can translate to frequencies, instruments, or other parameters. So do the scanners output shorter numbers if they read fewer lines? Or maybe the full number is padded with zeroes, which would be easy to strip off.
    -- If the scanners output shorter numbers/padded with zeroes when fewer bars are read, that means distance to the barcode would be one parameter of playing the instrument (and would be ideal). The result could be actualized in many different ways, like octave shift of the same note, etc. What I don’t know is how far away the scanners can reliably (or even somewhat reliably) read codes.
    -- I need maybe up to 16 scanners at once, and they will be wireless. The idea is a collaborative space with hundreds of codes all over the walls that multiple people can play. Maybe I’ll have barcode T shirts too, heh. If it’s only keystrokes it will be impossible to parse which scanner sent which data. (While not absolutely critical, it would be much preferred to know---each scanner could use different timbres, octaves, scales, etc from the same codes, and they could always be set to “unison parameters” if desired.) It looks like some scanners can use serial ports---if so, the data would already be separated by port and I’d just use multiple [serial] objects. Any experience with this?
    -- I’m thinking that most of the time the scanners would be on continuously so the data is a stream. What kind of rates are possible?
    -- Am planning to use printouts for the barcodes. However, am wondering if the scanners can read barcodes on screens, and if so, how well. This would allow installation of some screens in the space with dynamic codes.
    I realize that most answers will probably start with “Why don’t you get one and try it?!” Hehe. Absolutely…that’s the plan. But am curious if there’s any experience with all of this that could steer me in the right direction. Or away from wrong directions!

    • seejayjames's icon
      seejayjames's icon
      seejayjames
      Mar 17 2023 | 12:51 am
      Update: Got the scanner! Works great and the documentation is solid. Great wireless distance. It’s this one:
      https://www.amazon.com/dp/B0953DGLQX
      First got it working with [key], that was quick and easy, using the CR ASCII value (13) to know where the end is. It sends this so that you can enter values into a spreadsheet and it will auto-advance to the next cell down. Then with some configuration (in the User Manual there are a bunch of barcodes to tweak settings) I was able to get it through [serial], so this will allow differentiating multiple devices on different ports. I set the polling to 50ms because there doesn’t seem to be a way to know that something’s come in---when you set it to USB/serial, the key-based input (which does output immediately) is disabled. If there’s a setting that would allow [serial] to know something’s come in, please advise, because that would be more efficient. Note that this particular scanner only supports serial input on Windows.
      I’m subtracting 48 from the ASCII values so they map to the integers of the code itself, grouping them with [zl group], and looking for the CR (13) to bang out the collected list. Then I use [match] for the full code. Works great, will probably just have a subpatch with a whole slew of [match] objects for my notes and parameters...I don’t see that any other approach with [coll] etc would be any more streamlined. Of course, am open to suggestions.
      There’s a bit of latency but not too much...it’s certainly usable, especially if the tones are more fluid instead of percussive. I may use audio instead of MIDI because there’s more latency with the MIDI output (which comes from the OS). Or maybe I’ll try a combination, lots of possibilities.
      Was hoping there could be a way to tell how far the scanner is away from the code (by reading only parts of it as I described in the earlier post), but it doesn’t seem possible. The scanner needs to see the beginning and end lines to complete the read and to send the data, so it’s all or nothing.
      The scanner can indeed be set to “Continuous” with a special barcode. This will be very helpful as a performance option. In this mode, players can avoid accidentally triggering music codes if they turn the scanner sideways, cover the beam with their hand, get far enough away that it can’t read them, etc.
      On-screen barcodes don’t seem to work. There may be a contrast setting that would do it, but I haven’t gotten the black-on-white version to read at all.
      Anyway, just wanted to post this if anyone’s interested. With a bunch of scanners and codes, plus some carefully-chosen musical parameters, this could be really fun. If and when I make an installation I’ll post a video. Thanks everyone!
      Share
    • 110L532's icon
      110L532's icon
      110L532
      Mar 17 2023 | 9:23 pm
      Hi James, good to know you're well and still maxing.