Two weeks of Pibrella

pibrella-pcb-layoutSince my Pibrella arrived a couple of weeks ago i’ve been driving SWMBO & my posse of cats nuts by making it blink & squawk at all hours of the day and night while trying to get reasonable sound quality out of the piezo buzzer a la Camputers Lynx. There have been lots of “WHAT! are you doing?”, “Are you writing a program?”, “What’s that sound?”, “do you HAVE to do that now?” comments and cats suddenly appearing on my desk and sniffing and batting at the Pibrella. The Raspberry Pi+Pibrella has been knocked down more often than Chumbawumba. I’m still waiting on a solenoid and if it doesn’t arrive soon i’ll take a run, ok a jog, ok a slow stroll up the road to Radioshack & see what they have especially as now I have music sussed on the Pibrella I have the silly idea of using the wiringPi softTone function to have 5 piezo buzzers on a Pibrella play the same tune as a sort of 5 voice choir or performing a round.

Although I still haven’t played with the I/O on the Pibrella nothing in the last couple of weeks has changed my mind from the opinion that everyone who has a Raspberry Pi should have a Pibrella as well as it can be used for so many different things. So far i’ve used it as a rudimentary timer, a “clock”, a disco karaoke machine, a cat annoyer, a wife annoyer, a temperature indicator, an overclock indicator, a morse key and those are just the things i’m willing to admit to :)

I do have a few gripes but one of which I can’t really in all honesty blame Pimoroni or Cyntech for but I will 😀 My currently single Model A when I finally unboxed it after 8 months seems to have DOA USB. It looks like no power is going to the power pins in the USB slot :( and that was the Raspberry Pi the Pibrella was destined to be married to as it fits nicely on top of a Model A Pibow case & my plans for the Pibrella don’t require anything but a wifi dongle or a CC1000 in USB formfactor It’s all their fault :)

The second gripe IS Pimoroni’s fault and I hope their secret labs in darkest Sheffield are working on it. A Raspberry Pi with a Pibrella attached won’t fit neatly and safely in any case currently available, at least none I currently own so they need to do a few batches of Pibrella compatible layers. Layer 7, possibly 6 too & a nice clear top layer with holes for the leds, buzzer, I/O & button so that everything look pretty and fits snuggly

My final gripe is that the button is too clicky. i’d prefer something without so much feedback & volume but i’m sure much research was done before selecting the button they used so it might just be me that really doesn’t like the current one.

Just in case anyone else would like to take my efforts at playing music in a 80s home computer style & improve them i’m posting them below.

 

 

import pibrella, time, sys

#Note frequency for 8th Octave
notes  = { "C":4146, "C#":4435, "Db":4435, "D":4699, "D#":4978, "Eb":4978, "E":5274,
           "F":5588, "F#":5920, "Gb":5920, "G":6272, "G#":6645, "Ab":6645, "A":7040,
           "A#":7459, "Bb":7459, "B":7902, "R":0, "Q":0 }

def PlayMusic(tune):
  for i in range(0,(len(tune)-4),4):
    note=tune[i]
    if note != "Q":
      octave=8-tune[i+1]
      duration=tune[i+2]
      dots=tune[i+3]
      frequency = notes[note] / octave
      delay = 1000 / duration
      if dots == 1:
        delay = delay * 3/2
      if note == "R":
        pibrella.buzzer.stop()
      else:
          pibrella.buzzer.buzz(frequency)
      time.sleep(delay/1000.0)
  pibrella.buzzer.stop()

#PlayMusic takes an "array? list?" that contains a bunch of comma separated
# "note name",octave,duration,dotted e.g.
# "F",4,4,0,"G",3,2,1,.....
PlayMusic(eval('['+sys.stdin.read()+']'))

Some music to use with the above program.
Starwars.txt

"A#",2,4,0,"A#",2,4,0,"R",2,8,0,"F",3,4,0,"F",3,4,0,"R",2,8,0,"D#",3,8,0,"R",2,8,0,"D",3,8,0,"R                                       ",2,8,0,"C",3,8,0,"R",2,8,0,"A#",3,4,0,"A#",3,4,0,"R",3,8,0,"F",3,4,0,"R",2,8,0,"D#",3,8,0,"R",                                       2,8,0,"D",3,8,0,"R",2,8,0,"C",3,8,0,"R",2,8,0,"A#",3,4,0,"A#",3,4,0,"R",2,8,0,"F",3,4,0,"R",2,8                                       ,0,"D#",3,8,0,"R",2,8,0,"D",3,8,0,"R",2,8,0,"D#",3,8,0,"R",3,8,0,"C",3,4,0,"C",3,4,0,"Q",0,0,0

schooldays.txt

"D",7,2,1,"F",6,2,1,"C",7,2,1,"F",6,2,1,"Bb",6,2,0,"A",6,4,0,"Bb",6,2,0,"C",7,4,0,"Bb",6,2,1,"A",6,2,0,"R",6,4,0,"A",6,4,0,"Eb",7,4,0,"G",6,4,0,"A",6,4,0,"Eb",7,4,0,"G",6,4,0,"A",6,4,0,"R",6,4,0,"A",6,4,0,"A",6,2,1,"G",6,4,0,"D",7,4,0,"F",6,4,0,"G",6,4,0,"D",7,4,0,"F",6,4,0,"G",6,4,0,"R",6,4,0,"G",6,4,0,"G",6,2,1,"Q",0,0,0

heyjude.txt

"G",2,2,0,"E",2,2,0,"R",2,4,0,"E",2,4,0,"E",2,4,0,"G",2,4,0,"A",2,4,0,"D",2,2,0,"R",2,4,0,"D",2,4,0,"E",2,4,0,"F",2,2,0,"C",3,2,0,"C",3,4,0,"C",3,4,0,"B",2,4,0,"G",2,4,0,"A",2,4,0,"G",2,4,0,"F",2,4,0,"E",2,2,0,"R",2,4,0,"G",2,4,0,"A",2,4,0,"A",2,2,0,"A",2,4,0,"D",3,4,0,"C",3,4,0,"B",2,4,0,"B",2,4,0,"C",3,4,0,"A",2,4,0,"G",2,2,0,"R",2,4,0,"C",2,4,0,"D",2,4,0,"E",2,4,0,"A",2,4,0,"A",2,4,0,"G",2,2,0,"Q",0,0,0

furelise.txt

"E",4,2,0,"D#",4,2,0,"E",4,2,0,"D#",4,2,0,"E",4,2,0,"B",3,2,0,"D",4,2,0,"C",4,2,0,"A",3,2,0,"R",4,2,0,"C",3,2,0,"E",3,2,0,"A",3,2,0,"B",3,1,0,"R",4,2,0,"E",3,2,0,"G#",3,2,0,"B",3,2,0,"E",4,1,0,"R",4,2,0,"E",3,2,0,"E",3,2,0,"D#",4,2,0,"E",4,2,0,"D",4,2,0,"E",4,2,0,"B",3,2,0,"D",4,2,0,"C",4,2,0,"A",3,2,0,"R",3,2,0,"C",3,2,0,"E",3,2,0,"A",3,2,0,"B",3,1,0,"R",4,2,0,"E",3,2,0,"C",4,2,0,"B",3,2,0,"A",3,1,0,"Q",0,0,0

I also did the obvious thing & took the above program & turned it into a simple keyboard/organ :)

import pibrella, time, sys, tty, termios

notes  = { "A":4146, "Q":4435, "Z":4435, "S":4699, "W":4978, "X":4978, "D":5274,
           "E":5588, "C":5920, "F":5920, "R":6272, "V":6645, "G":6645, "T":7040,
           "B":7459, "H":7459, "Y":7902 }

#notes  = { "C":4146, "C#":4435, "Db":4435, "D":4699, "D#":4978, "Eb":4978, "E":5274,
#           "F":5588, "F#":5920, "Gb":5920, "G":6272, "G#":6645, "Ab":6645, "A":7040,
#           "A#":7459, "Bb":7459, "B":7902 }



def PlayNote(frequency,octave):
    pibrella.light.off()
    if frequency >=4146 and frequency <= 4978:        pibrella.light.red.on()     elif frequency >= 5274 and frequency <=6645:        pibrella.light.amber.on()     else:        pibrella.light.green.on()     frequency = frequency / octave     pibrella.buzzer.buzz(frequency) fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) tty.setraw(sys.stdin.fileno()) print "@ukscone's wonderful PiBrOrgan\r" octave=4 while 1:     ch = sys.stdin.read(1)     if ch=='\r':         break     elif ch==' ':         pibrella.light.off()         pibrella.buzzer.stop()     elif ch >= '1' and ch <= '8':
        octave=eval(ch)
    elif ch.upper() in notes:
        PlayNote(notes[ch.upper()],octave)

termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)

They really aren’t that good but hopefully they’ll be inspiration for someone to do better.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

 

russelldavis.org © 2014 Frontier Theme