ATtiny85 MIDI to CV

March 2, 2019 at 4:07 pm (computers, music) (, , , )

There are a number of projects out there that provide a MIDI to CV function utilising some flavour of the ATtiny family of microcontrollers.  But most of them go from USB MIDI to CV but I wanted a genuine 5-pin DIN MIDI to CV.  This was the result.

It has taken a basic MIDI in circuit from the Internet (Google will find a few of these kicking around) and pairs it with the ATtiny85 CV out section of Jan Ostman’s cheap USB MIDI 2 CV design.

Update: Jan Ostman has now written a tutorial on how to do this directly using the USI on the ATtiny85. Read it directly from the expert here http://blog.dspsynth.eu/diy-good-ol-midi-to-cv/ Must now go and update my MIDI handling to do it properly! ūüôā

The result is as follows (excuse the poor representation in Fritzing, it served its purpose). Note that the 6N138 only had 5 active pins in the Fritzing part, so the extra dodgy link shown below is a fudged link for pin 7 to GND via a 4.7k resistor.

MIDItoCV2_schem

I also have a version for the ATtiny2313, but the main changes are as you’d expect.  Basically I was having problems with the ATtiny85 missing MIDI messages and wondered if a hardware UART would be better.  Turned out it was just my dodgy code with no real error checking getting out of sync with the MIDI stream.  But it took trying it on a 2313 to highlight the real issue, so back to the ATtiny85 and now all is well.

The MIDI handling in the code is about as basic as it comes – it really ought to have a proper state machine to support chained note on messages, but for now this is a fair start.

Design wise, its fairly simple ATtiny85 wise with the pin usage as follows:

  • SoftwareSerial receive on D3 (PB3) which is physical pin 2.
  • Gate output on D2 (PB2) which is physical pin 7.
  • CV output using the PWM signal tied to OC1A triggered off timer 1, which is D1 (PB1) on physical pin 6.

The code uses the same trick that Jan Ostman used in his code – if the top compare value for PWM operation is 239 then there are 240 graduations for PWM.  To cover a MIDI range of C2 (note 36) to C7 (note 96) is 60, so the PWM compare value required for a linear CV voltage output is basically (note-36)*4.

In terms of timer control registers, this all translates over to (refer to the ATtiny85 data sheet):

  • Set PWM1A i.e. PWM based on OCR1A
  • Set COM1A1 i.e. Clear OC1A (PB1) output line
  • Set CS10 i.e. Prescaler = PCK/CK i.e. run at Clock speed
  • Clear PWM1B is not enabled (GTCCR = 0)

The value for the PWM cycle is set in OCR1C to 239, and the compare value is set in OCR1A between 0 and 239, thus representing a range of 0 to 5v giving 1v per octave, assuming a 5v power supply.

When porting to the ATtiny2313, a similar scheme was used, but timer 1 is a 16 bit timer, and the control registers were slightly different, but I still used the 0-239 range.

Reading around the different modes, I ended opting for the use of Fast PWM with the compare value in OCR1A and the maximum PWM cycle value (239) in ICR1.  The timer register settings were thus as follows:

Timer 1 Control Register A (TCCR1A):

  • 7 COM1A1 = 1 COM1A1(1); COM1A0(0) = Clear OC1A on compare match; set at TOP
  • 6 COM1A0 = 0
  • 5 COM1B1 = 0
  • 4 COM1B0 = 0
  • 3 Resv = 0
  • 2 Resv = 0
  • 1 WGM11 = 1 WGM11(1); WGM10(0) = PWM from OCR1A based on TOP=ICR1
  • 0 WGM10 = 0

Timer 1 Control register B (TCCR1B):

  • 7 ICNC1 = 0
  • 6 ICES1 = 0
  • 5 Resv = 0
  • 4 WGM13 = 1 WGM13(1); WGM12(1) = PWM from OCR1A based on TOP=ICR1
  • 3 WGM12 = 1
  • 2 CS12 = 0 CS12(0); CS11(0); CS10(1) = Prescaler = PCK/CK i.e. run at Clock speed
  • 1 CS11 = 0
  • 0 CS10 = 1

Timer 1 Control Register C left all zeros.

I don’t know if it was the version of the ATtinyCore I was using, but the bit and register definitions for Timer1 for the ATtiny2313 didn’t seem to match the datasheet, so I just used the bit codes directly.

In terms of ATtiny2313 pin definitions, the following were used:

  • Hardware serial receive on D0 (PD0) which is physical pin 2.
  • Gate output on D11 (PB2) which is physical pin 14.
  • CV output using the PWM signal tied to OC1A triggered off timer 1, which is D12 (PB3) on physical pin 15.

A quick note on the MIDI serial handling.  My first code was very lazy and basically said:

Loop:
  IF (serial data received) THEN
    read MIDI command value
    IF (MIDI note on received) THEN
      read MIDI note value
      read MIDI velocity value
      set CV out value based on MIDI note value
      set Gate signal HIGH
    ELSE IF (MIDI note off received) THEN
      read MIDI note value
      read MIDI velocity value
      set CV out value based on MIDI note value
      set Gate signal LOW
    ELSE
      ignore and go round again waiting for serial data
    ENDIF
  ENDIF
END Loop

This generated a very quirky set of issues.  Basically when there was serial data available and a MIDI note on or off command detected, the read of the note and velocity data was returning and error (-1) which I never bothered checking.  Basically the code was running too fast and the next MIDI byte hadn’t registered yet.  So when (-1) was passed on as the MIDI note, it was resulting in a note on code thinking the MIDI note was 255, which was rounded up to the highest note (96).

The result was that I could see the gate pulsing in response to MIDI note on and off messages, but the CV voltage went high as soon as the first MIDI message was received.

I now use a test that says

IF (at least three bytes of serial data received) THEN

which means that if things get out of sync, eventually bytes are skipped until there are three bytes that equate to a note on/off message.  Crude, but it works for now.  Eventually as I say, it might get a proper state machine (or I’ll pull in a proper MIDI library).

I used the 8MHz internal clock for the ATtiny85. It includes a CVOUTTEST mode that ignores the serial bit and just generates an internal sequence of increasing nodes between 36 and 96 that can be used to test the PWM output without worrying about the MIDI side of things.

To test all of it together, I used my ATtiny85 MIDI Tester.

I might add some kind of selection for the MIDI channel.  Right now its hard-coded in a #define.  One option might be using an analogue input and a multi-position switch with a resistor network.  Or maybe a “tap to increase the channel” digital input switch.  Or if I use the 2313 version, I could use more pins and use a BCD or hex rotary switch or DIP switches.

2019-03-02 16.00.27

Here is the full code for the ATtiny85 version then. 

// MIDI to CV using ATTiny85
#include <SoftwareSerial.h>

//#define CVOUTTEST 1

#define MIDIRX 3  // 3=PB3/D3 in Arduino terms = Pin 2 for ATTiny85
#define MIDITX 4  // 4=PB4/D4 in Arduino terms = Pin 3 for ATTiny85
#define MIDICH 1  // Set to the MIDI channel to use (1 to 16)
#define MIDILONOTE 36
#define MIDIHINOTE 96

// Output:
//  PB2 (Ardiuno) = Pin 7 = Gate Output
//  PB1 (Arduino) = Pin 6 = Pitch CV Output
//
// PB5 set as digital output
// PB1 used as PWM output for Timer 1 compare OC1A
#define GATE    2  // PB2 (Pin 7) Gate
#define PITCHCV 1  // PB1 (Pin 6) Pitch CV

SoftwareSerial Serial(MIDIRX, MIDITX);

void setup() {
  // put your setup code here, to run once:
  Serial.begin (31250); // MIDI Baud rate

  pinMode (GATE, OUTPUT);
  pinMode (PITCHCV, OUTPUT);

  // Use Timer 1 for PWM output based on Compare Register A
  // However, set max compare value to 239 in Compare Register C
  // This means that output continually swings between 0 and 239
  // MIDI note ranges accepted are as follows:
  //    Lowest note = 36 (C2)
  //    Highest note = 96 (C7)
  // So there are 60 notes that can be received, thus making each
  // PWM compare value 240/60 i.e. steps of 4.
  //
  // So, for each note received, PWM Compare value = (note-36)*4.
  //
  // Timer 1 Control Register:
  //   PWM1A = PWM based on OCR1A
  //   COM1A1 = Clear OC1A (PB1) output line
  //   CS10 = Prescaler = PCK/CK i.e. run at Clock speed
  //   PWM1B is not enabled (GTCCR = 0)
  //
  TCCR1 = _BV(PWM1A)|_BV(COM1A1)|_BV(CS10);
  GTCCR = 0;
  OCR1C = 239;
  OCR1A = 0; // Initial Pitch CV = 0 (equivalent to note C2)
  digitalWrite(GATE,LOW); // Initial Gate = low
}

void setTimerPWM (uint16_t value) {
  OCR1A = value;
}

void loop() {
  // put your main code here, to run repeatedly:
  byte midi_c;
  byte midi_note;
  byte midi_vel;

#ifdef CVOUTTEST
  for (midi_note=36; midi_note<=90; midi_note++) {
    midiNoteOn (midi_note);
    delay (500);
    midiNoteOff (midi_note);
    delay (500);
  }
#else
  // Massively simplified MIDI read here, assumes
  // only ever get note on/off messages in triplets, which isn't actually true!
  // For a full MIDI decoder, see: http://www.gammon.com.au/forum/?id=12746
  //
  // Note: Only looking for commands on one channel
  //
  if (Serial.available()>=3) {
    midi_c = Serial.read();
    // MIDI commands have top bit set
    if (midi_c == 0x90+MIDICH-1) {
      // MIDI note on
      midi_note = Serial.read();
      midi_vel  = Serial.read();
      if (midi_note != 255) {
        if (midi_vel == 0){
          // Receiving vel of 0 is same as a note off event
          midiNoteOff (midi_note);
        } else {
          midiNoteOn (midi_note);
        }
      }

      // If further data exists, could be more note/vel pairs associated with
      // the same note on command, so should really keep decoding data stream
      // until find another MIDI command, but as the CV has no concept of
      // polyphony, we are just working with the first note on command received.
      //
      // This means that we could get out of sync in terms of pairing note
      // on and off events ... but then any note off will stop the Gate signal...
    }
    else if (midi_c == 0x80+MIDICH-1) {
      // MIDI note off
      midi_note = Serial.read();
      midi_vel  = Serial.read();
      if (midi_note != 255) {
        midiNoteOff (midi_note);
      }
    }
    else {
      // Command or data we don't process
    }
  }
#endif
}

void midiNoteOn (byte midi_note) {
  // check note in the correct range of 36 (C2) to 90 (C7)
  if (midi_note < MIDILONOTE) midi_note = MIDILONOTE;
  if (midi_note > MIDIHINOTE) midi_note = MIDIHINOTE;

  // Scale to range 0 to 239, with 1 note = 4 steps
  midi_note = midi_note - MIDILONOTE;

  // Set the voltage of the Pitch CV and Enable the Gate
  digitalWrite (GATE, HIGH);
  setTimerPWM(midi_note*4);
}

void midiNoteOff (byte midi_note) {
  // check note in the correct range of 36 (C2) to 90 (C7)
  if (midi_note < MIDILONOTE) midi_note = MIDILONOTE;
  if (midi_note > MIDIHINOTE) midi_note = MIDIHINOTE;

  // Scale to range 0 to 239, with 1 note = 4 steps
  midi_note = midi_note - MIDILONOTE;

  // Set the voltage of the Pitch CV and Enable the Gate
  digitalWrite (GATE, LOW);
  setTimerPWM(midi_note*4);
}

 

Advertisements

Permalink Leave a Comment

ATtiny85 MIDI Tester

January 25, 2019 at 10:28 pm (computers, music) (, , )

Having spent some time messing about with building simple synthesizer circuits, I’m putting together a simple MIDI to CV converter.¬† I have one using an ATtiny85 but think I’m struggling from the fact it is only using SoftwareSerial, so I plan to have another go with an ATtiny231w pretty soon now.

One thing I was missing though was a simple “hands free” MIDI tester.¬† Now it would be fairly simple to hook up my laptop or a keyboard to a MIDI cable and use that, but I wanted something I could just plug in and leave sending MIDI data out to whatever I was building.¬† So the idea of using a simple USB-powered ATTiny85 to creating a continuous set of MIDI note on and not off messages was born.

I’m using one of those cheap Digispark USB clones you can buy. I had no luck ever getting the USB programming side of it to work, (its supposed to be able to have the nucleus boot loader installed to provide a software USB implementation), but its easy to programme if you have an 8-pin DIL test clip, in my cased hooked up to a sparkfun tiny programmer.

2019-01-25 21.22.26

Basic design notes for the board:

  • P1 (equivalent to Arduino D1 and the ATtiny85 pin 6) has the built-in LED.
  • I’m using P2 as MIDI TX and P3 as (unused) MIDI RX (D2 and D3, mapped to ATtiny85 pins 7 and 2).
  • P0 (ATtiny85 pin 5) as a digital input with internal pull-up resistors enabled.

I’m using a simple MIDI out circuit from the Internet that shows:

  • DIN pin 5 – MIDI OUT signal directly connected to P2.
  • DIN pin 2 – MIDI ground.
  • DIN pin 4 – MIDI +5v via a 220R resistor.

The resistor was soldered inside an in-line female MIDI DIN socket.

2019-01-25 21.36.522019-01-25 21.42.10

A switch was soldered across from P0 to GND on the Digispark board.¬† The code will flash the LED when the switch is registered so you know you’ve done something.

That is pretty much it.

2019-01-25 21.51.47

2019-01-25 21.51.56

In terms of code, I just tested it with an increasing scale of a few octaves, with the switch being used to increase the tempo (by reducing the delay between notes). Of course, you can use whatever test pattern works for you.

My initial (simple) code below.

Important: You must “set the fuses” to use the internal 16MHz clock in order to get the MIDI baud rates for the SoftwareSerial implementation.

Kevin

// MIDI Code Test Generator using ATtiny85
// NB: Use Sparkfun USB ATtiny85 Programmer
//     Set Arduino env to USBTinyISP
//     Set 16MHz Internal Clock (required for MIDI baud)
#include <SoftwareSerial.h>

// Pin Mapping for DigiSpark USB/ATtiny85
//  P0 = PB0/D0 = Pin 5 Attiny85
//  P1 = PB1/D1 = Pin 6 - built-in LED
//  P2 = PB2/D2 = Pin 7
//  P3 = PB3/D3 = Pin 2 - wired to USB+
//  P4 = PB4/D4 = Pin 3 - wired to USB-
//  P5 = PB5/D5 = Pin 1 - wired to RESET
//
// Use the Arduino D numbers below (which are the same as Digispark P numbers)
#define MIDITX   2
#define MIDIRX   3
#define BUTTON   0
#define BLTINLED 1

// MIDI Parameters for testing
#define MIDI_CHANNEL     1
#define MIDI_LOWNOTE     36
#define MIDI_HIGHNOTE    90
#define MIDI_VELOCITY    64
#define MIDI_DELAYMAX    550
#define MIDI_DELAYMIN    50
#define MIDI_DELAYSTEP   100

#define MIDI_NOTEON      0x90
#define MIDI_NOTEOFF     0x80

SoftwareSerial midiSerial(MIDIRX, MIDITX);

int delayRate;
int buttonState;
int lastButtonState;
byte midiNote;

void setup() {
  // Switch will trigger HIGH->LOW
  pinMode (BUTTON, INPUT_PULLUP);
  pinMode (BLTINLED, OUTPUT);
  digitalWrite (BLTINLED, LOW);
  buttonState = HIGH;
  lastButtonState = HIGH;
  
  midiSerial.begin (31250); // MIDI Baud rate

  delayRate = MIDI_DELAYMAX;
  midiNote  = MIDI_LOWNOTE;
}

void loop() {
  buttonState = digitalRead (BUTTON);
  if ((lastButtonState == HIGH) && (buttonState == LOW)) {
    ledOn();
    delayRate = delayRate - MIDI_DELAYSTEP;
    if (delayRate < MIDI_DELAYMIN) delayRate = MIDI_DELAYMAX;
  }
  lastButtonState = buttonState;

  midiNoteOn (MIDI_CHANNEL, midiNote, MIDI_VELOCITY);
  delay (400); // Need note on long enough to sound
  midiNoteOff (MIDI_CHANNEL, midiNote);
  delay (delayRate);

  midiNote++;
  if (midiNote > MIDI_HIGHNOTE) midiNote = MIDI_LOWNOTE;
  
  ledOff();
}

void midiNoteOn (byte midi_channel, byte midi_note, byte midi_vel) {
  midiSerial.write (midi_channel+MIDI_NOTEON);
  midiSerial.write (midi_note);
  midiSerial.write (midi_vel);
}

void midiNoteOff (byte midi_channel, byte midi_note) {
  midiSerial.write (midi_channel+MIDI_NOTEOFF);
  midiSerial.write (midi_note);
  midiSerial.write ((byte)0);
}

void ledOn () {
  digitalWrite (BLTINLED, HIGH);
}

void ledOff () {
  digitalWrite (BLTINLED, LOW);  
}

Permalink 1 Comment

MIDI Arp

December 1, 2015 at 11:17 pm (computers, internet, music) (, , , , )

I wanted to do something with MIDI and Arduino.¬† I’ve just picked up some cheap¬†Arduino Nano Ethernet shields, based on the Microchip ENC28J60, so thought I’d combine the two.¬† The ENC28J60 and a cheap¬†Arduino Nano makes for a very compact and economical Ethernet ready microcontroller and I have a nice Roland MT-32 Synth module gathering dust that I wanted to try again.

2015-12-01 21.16.05

My initial idea was to use MIDI to trigger sounds based on arp requests received by the Arduino, (hence the name MIDI Arp), but then decided that on my home network arp requests wouldn’t give a lot of variation, so I decided to see if I could trigger on the destination IP address of any packet received.

First I needed the MIDI interface.  I followed the simple circuit and example provided on the Arduino website, but wanted it all self-contained inside a MIDI plug rather than on a breadboard, so I soldered up the 220 resistor inside a 5 pin MIDI DIN plug as follows (MIDI pins are number 1, 4, 2, 5, 3 for some reason):

  • Arduino GND – Brown – MIDI Plug pin 2
  • Arduino 5v – Red – 220 Ohm resistor – MIDI Plug pin 4
  • Arduino TX (Pin 1) – Orange – MIDI Plug pin 5

This was then connected to the Arduino and the MIDI test programme showed that all works fine.

2015-12-01 21.16.212015-12-01 21.19.13

So, to the Ethernet side of things.  The following is an excellent starting place for the ENC28J60 based nano shield:

After reading this, I decided to use the UIPEthernet library as my starting point as I liked the idea of a plug-in replacement to the standard Arduino Ethernet library.  There was two major things to work out Рfirst, how to set the device into some kind of promiscuous mode, assuming it supports it at all; second how to grab the destination IP address from any received packets.

From the ENC28J60 data sheet, the key register that controls the receiver filtering is the Ethernet Receive Filter Control Register – ERXFCON (see section 8 ‘Receive Filters’).¬† There are a number of modes for filtering and the UIPEthernet library is set up to filter for the unicast address associated with the MAC address configured for the module, for broadcasts, and to use the pattern matching filter to spot arp packets.¬† It turns out that to set the receiver into promiscuous mode, this register just has to be set to zero.

Now this is where things got lazy.  I just dived into the UIPEthernet library sitting in my Arduino library folder and hacked about. I might tidy this up one day and do it properly.

The low-level driver code can be found in utility/Enc38j60Network.cpp.  In the Enc28J60Network::init function, there is a line that sets up the ERXFCON register:

writeReg(ERXFCON, ERXFCON_UCEN|ERXFCON_CRCEN|ERXFCON_PMEN|ERXFCON_BCEN);

This needs to simply be changed to clear the register:

writeReg(ERXFCON, 0);

Next, how to store the destination IP address.  Again, simplicity ruled this one too.

The high-level interface to the library can be found in UIPEthernet.cpp and UIPEthernet.h.  I added two public functions and two private variables to the UIPEthernetClass class in UIPEthernet.h:

public:
  IPAddress lastSrcIP();
  IPAddress lastDestIP();
private:
  static uip_ipaddr_t uip_lastipsrc;
  static uip_ipaddr_t uip_lastipdest;

Then in the UIPEthernet.Cpp file, added the code to store the last source and destination IP addresses from received packets.

First, define a structure to dig into to the IP header (a bit of a layer violation, but I wasn’t after neat designs really).¬† Add the following after the definition of ETH_HDR near the top of the file.

#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])

Then add two (static) global variables to the file:

uip_ipaddr_t UIPEthernetClass::uip_lastipsrc;
uip_ipaddr_t UIPEthernetClass::uip_lastipdest;

Add two accessor methods to retrieve the last source and destination IP addresses (with appropriate conversion to the Arduino Ethernet friendly IPAddress format):

IPAddress UIPEthernetClass::lastSrcIP()
{
  return ip_addr_uip(uip_lastipsrc);
}
IPAddress UIPEthernetClass::lastDestIP()
{
  return ip_addr_uip(uip_lastipdest);
}

Finally add the code to save the addresses to the UIPEthernetClass::tick() function, on reception of a packet.

          Enc28J60Network::readPacket(in_packet,0,(uint8_t*)uip_buf,UIP_BUFSIZE);
          if (ETH_HDR ->type == HTONS(UIP_ETHTYPE_IP))
            {
              uip_packet = in_packet; //required for upper_layer_checksum of in_packet!
#ifdef UIPETHERNET_DEBUG
              Serial.print(F("readPacket type IP, uip_len: "));
              Serial.println(uip_len);
#endif
              uip_arp_ipin();
              uip_input();
              if (uip_len > 0)
                {
                  uip_arp_out();
                  network_send();
                }
                // Extra code added here
                uip_ipaddr_copy(uip_lastipsrc, IPBUF->srcipaddr);
                uip_ipaddr_copy(uip_lastipdest, IPBUF->destipaddr);
                // Extra code ends
            }

That should be all that is required to expose the destination IP address of any received packet via the UIPEthernet class (ok, breaking compatibility now with the standard Arduino Ethernet library).

The arduino sketch file now consists of the following:

/*
MIDI based on 
 http://www.arduino.cc/en/Tutorial/Midi

UIPEthernet Examples used for rest
NB: Requires hacked UIPEthernet Library!
 */
#include <SPI.h>
#include <UIPEthernet.h>
#include "IPAddress.h"

int lastIP;
int thisIP;

// Initialise note array with whole tone scales in octaves 3 through to 6
// C3 = 36
// C4 = 48
// C5 = 60
// C6 = 72
// C7 = 84
#define NOTES 24
int notes[NOTES] = {
  // C3  D3  E3  F#3 G#3 A#3
     36, 38, 40, 42, 44, 46,
  // C4
     48, 50, 52, 54, 56, 58,
  // C5
     60, 62, 64, 66, 68, 70,
  // C6
     72, 74, 76, 78, 80, 82
};

void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);

  // Initialise the uIP and UIPEtherent stacks
  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  IPAddress myIP(192,168,0,6);
  
  lastIP = 0;
  thisIP = 0;

  Ethernet.begin(mac,myIP);
  
  // Initialise patch using program change
  // 32 = Synth 1, Fantasy
  midiCmd (0xC0, 32);
}

void loop() {
  Ethernet.maintain();
  IPAddress sip = Ethernet.lastSrcIP();
  IPAddress dip = Ethernet.lastDestIP();
  thisIP = 256*dip[2] + dip[3];
  
  if (thisIP != lastIP)
  {
    lastIP = thisIP;
  
    int note = (thisIP & 0xff) % NOTES;  // Scale to number of notes
    int vel  = ((thisIP & 0xff00) >> 8)/4;        // Scale to val between 0 and 64

    //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, notes[note], 16+vel);
  }
}

//  plays a MIDI note.  Doesn't check to see that
//  cmd is greater than 127, or that data values are  less than 127:
void noteOn(int cmd, int pitch, int velocity) {
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(velocity);
}

void midiCmd(int cmd, int val) {
  Serial.write(cmd);
  Serial.write(val);
}

The final byte of the IP address determines which note from the array of notes to play (modulo the number of notes) and the third byte determines the volume to be used, scaled and with a minimum specified.

There is a control message to set the voice on the MT-32 to Synth1-Fantasy as this sounds suitably ambient. There are no note-off messages, so notes are allowed to keep ringing. As the note array defines four octaves of whole tone scales, the running-on notes create quite an interesting effect.

2015-12-01 21.40.12

There seems to be a regular drone set up, which I think is due to the IP address of my PC and router. These two addresses provide a sort of default back-drop of sound to anything else going on.

In order to get anything useful though, it would be no good just using a port on the router, as even the dumbest, cheap modern router will tend to do some MAC level filtering on ports. I had a laptop and the Arduino plugged into an old Netgear En104 4-port Ethernet hub, which has no intelligence (as far as I know) built in – so the Arduino could see everything coming out of the laptop.

The results were quite pleasing. Google has a nice enhanced drone to it. You can really hear the clutter of a site that is pulling in ads from all over the Internet – such as Amazon or YouTube or a news site.

Edited to add:¬†¬†Here is a short video below showing them being opened. ¬†It’s a bit crude but you get the general idea.

¬†Maybe next, I’ll see if I can do the same with a Wi-Fi link for the Arduino instead of wired Ethernet. ¬†It might also be worth trying different scales and alternative mappings of notes to addresses.

Kevin

Permalink Leave a Comment

Tenori-on

January 20, 2011 at 10:07 pm (music) (, , , , )

Had the great chance to go and watch Bill Bailey recently as part of his Dandelion Mind tour, at the Wyndhams Theatre in London.¬† Absolutely fantastic (his cover of Gary Newman’s Cars was just great).

One thing that really caught my attention though, was his use of a curious Japanese digital Instrument.  Its a grid of LEDs and switches.  You touch the switch and that LED will activate a note when it lights up.  Then as the instrument keeps sweeping across the grid, the lit LED will keep playing the note.  Its a really curious effect.

Well, others seem to have thought so too as a Google search for Bill Bailey Japanese instrument reveals all Рits a Tenori-on, made by Yamaha Рand you can have your own for the cool price of around £600!

Well, Tenori-on or an iPad … hmm.¬† Still, would be a really neat instrument to have … maybe time to dig out that old R.A.Penfold book of MIDI projects …

Kevin.

 

Permalink 1 Comment

How Many Notes in Mozart’s Requiem?

December 7, 2009 at 9:14 pm (computers, music) (, , , )

When some bright spark suggests a ‘how many notes in the score’ competition, I thought what piece could be better than Mozart’s Requiem?¬† 4 choral parts, orchestra, I could have the vocal score on hand for reference and estimating, etc, etc.¬† One problem – just how many notes are then in Mozart’s Requiem?

Well, when Google failed me, and I counted how many notes in one bar of the score (more than 40), I decided extrapolating from a sample of bars to the whole piece was impractical, I thought I’d look for help of a more technical kind.

Googling eventually found me a site with the complete Requiem as a series of MIDI files.¬† Great – thought I’d just load them into a sequencer and that would do the job.¬† But no, the sequencer’s I have and tried didn’t have a ‘total notes’ statistic anywhere that I could find.

Well, this is the point where the geek takes over … MIDI is just a series of instructions ‘turn this note on, turn this note off, change to violin here’ and so on.¬† So, armed with the MIDI files, I just have to find something that would count the ‘note on’ events in each track in each file.¬† Well, after a bit of playing around, and looking for help, I found the MIDI perl library.¬† This enabled the following script (stored here in case someone else has the same whimsical, insane idea and needs to do something similar).

#!/usr/bin/perl
use MIDI;

my $opus = MIDI::Opus->new({'from_file' => $ARGV[0]});
my $notes = 0;
my @tracks = $opus->tracks();
foreach my $track (@tracks)
{
   foreach my $event ($track->events())
   {
      if ($event->[0] eq 'note_on')
      {
         $notes++;
      }
   }
}
print "Note count: $notes\n";

And the number of notes? Ah, well that would be telling … lets just say that whoever said Mozart used ‘too many notes’ really just didn’t know what they were talking about …

Kevin.

Permalink 4 Comments

Online Karaoke

January 2, 2008 at 10:23 pm (interesting, internet, music) (, , , )

Whilst searching for some lyrics online, I came across this site – Ronan’s Online Karaoke. It has a wide selection of tracks with lyrics and simple accompaniments.¬† What was interesting to me, is that the tracks are mostly in MIDI format – which means you can load them into your favourite sequencer and start playing around with them – even seeing notation.¬† Cool.

Kevin.

Permalink Leave a Comment