1
\$\begingroup\$

I'm curious about the possibility of sonifying MIDI data, which has a bitrate of 31250. The range of human hearing extends to about 20kHz, which means that the fastest bits of the signal would lie near the top of this range: not ideal for my purposes. I envision stretching the signal, and then passing the result to a small speaker.

I'm not sure if there is a more precise term for this operation than "stretching" (I'm not super familiar with digital signal processing). At any rate, I can provide a concrete example of what I mean:

00101110100001 >> stretch by 2 >> 0000110011111100110000000011

Not unlikely, the resulting sound will seem be rather atonal/noisy, and that's OK by me. I imagine that I could accomplish this task with Arduino, but I'm wondering about whether this could be done with clever circuit design. For instance, something akin to using a 4018 divide-by-N counter IC? I recognize that the 4018 isn't exactly what I'm looking for, since this acts on a strictly periodic clock signal.

Any ideas?

\$\endgroup\$
  • \$\begingroup\$ So essentially you want to make a high-frequency random bit stream (just some binary data) audible? To slow it down, you are either a) going to extends its duration, for example 1 second of bits at 31,250b/s will last, say 3 seconds, or b) some of the data will be thrown away, say 2 out of every 3 bits. Do you have any preference? If it is literally played as bits, without further processing, it will sounds like random 'white' noise. \$\endgroup\$ – gbulmer Sep 18 '14 at 19:17
  • \$\begingroup\$ Thank you for that succinct analysis @gbulmer. I'm specifically looking for option A (extending the duration). I suspect that option B could be realized by using a 4018. \$\endgroup\$ – jptacek Sep 18 '14 at 19:39
  • \$\begingroup\$ Extend the duration, so that all bits are eventually played, will require memory. That could be because the MIDI data can be read and re-read, e.g. from a storage device. Otherwise, the 'delay line' needs enough storage to hold the data. So how long a piece of MIDI data are you thinking? Five minutes at 31250b/s (almost 4kB/s) = 1,144kB, i.e. over 1MB. \$\endgroup\$ – gbulmer Sep 18 '14 at 19:46
  • \$\begingroup\$ actually it is pretty funny... I tried opening a MID file (although this is not a proper MIDI stream) as RAW in a audio editor (as 8-bit signed, 11.025 kHz), and it makes some kind of structured (noisy) sounds ;-) \$\endgroup\$ – Ale Sep 18 '14 at 22:23
  • 1
    \$\begingroup\$ Maybe look into frequency-shift keying (FSK), or see if you can find an old BEL 103 acoustic phone modem or ham radio packet radio set? This would at least sound more "musical" than white noise, you'd be able to hear the mark and space bits more clearly. (Otherwise you only hear the 0-1 and 1-0 transitions.) Granted now you're making "modem noise" instead of white noise, but it's your project... \$\endgroup\$ – MarkU Sep 20 '14 at 7:26
3
\$\begingroup\$

Since MIDI data appears to be a series of 8-bit data bytes as sent by a standard UART, you could use a microcontroller to receive the data at the standard MIDI rate, and re-transmit it at a lower baud rate. This assumes that there are sufficient gaps in the data that you won't over-run the receive buffer.

This would probably require a microcontroller with two UARTs, as the UARTs I've used don't allow different transmit and receive speeds.

\$\endgroup\$
  • 2
    \$\begingroup\$ MIDI data is very intermittent; you could probably slow the baud rate down by a factor of 10 and not lose a significant amount of data, even with just a few hundred bytes of buffer. Any small micro could do this; just bit-bang the output signal instead of using a second UART. \$\endgroup\$ – Dave Tweed Sep 18 '14 at 20:19
1
\$\begingroup\$

So essentially you want to make a high-frequency random bit stream (just some binary data) audible. If it is literally played as bits, without further processing, it will sounds like random 'white' noise.

To slow it down, either :

  1. extend its duration, for example 1 second of bits at 31,250b/s will last, say 3 seconds, or
  2. throw some of the data away. Say 2 out of every 3 bits will get it into an audible range

For a simple, but interesting way, to throw bits away you could use a technique used in some 'bat listening devices'. They use a shift register, initialised with a single '1' and the rest is '0's.

The shift registers output is fed back to the input, and the output would drive the audio. The clock for the shift register is the signal. So a sequence of '1's in the signal will be merged into 1/2 clock, and a sequence of '0's will be merged into 1/2 clock.

So it tends to preserve changes. By careful choice of the length of the shift register, you can divide by a suitable amount.

To extend the duration, so that all bits are eventually played, will require memory. That could be because the MIDI data can be read and re-read, e.g. from a storage device.

Otherwise, the 'delay line' needs enough storage to hold the data. Five minutes at 31250b/s (almost 4kB/s) = 1,144kB, i.e. over 1MB.

It would be straightforward to make something like that with any device with enough RAM, like an R-Pi or BeagleBone black. It could be made using a MCU, like an Arduino, with the addition of some external storage. Don't use Flash memory for the storage unless you only plan on using this rarely, or the external storage is much bigger than a 'track', because Flash memory will eventually wear out.

\$\endgroup\$
0
\$\begingroup\$

How about something like a 4027 JK flip-flop configured to toggle its output (J & K pulled high) ? This would effective reduce the maximum possible frequency by half. The result using your example would be: 00101110100001 >> flip-flop >> 00110000111110 Not the same bit-stream by any stretch of the imagination, but I suspect you're not really looking for accuracy here ...

\$\endgroup\$
  • \$\begingroup\$ Actually, I am looking to preserve the fidelity of the bit stream. I acknowledge that the end result will just sound like noise, anyway. \$\endgroup\$ – jptacek Sep 18 '14 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.