8bit Mix Tape

From SGMK-SSAM-WIKI
Jump to: navigation, search

Overview

The 8bit MixTape is an arduino compatible sound gadget, based on the Babygnusbuino (anyma) and Viznut's "Algorithmic symphonies from one line of code", put together by dusjagr, ucok and iyok...

Prototypes

v0.1

8bit mixedTapev01.jpg


First version using a BabyGnusbuino attached to a card-board tape dummy

v0.2

8bit mixedTapev02.jpg

New version, v0.2, nicely fits into a tape, with battery, USB programming interface, LEDs and a button to choose different codes.


v0.3

based on Babygnusbuino-v2

8bit mixedTapev03.jpg

v0.4

for on board soldering

480px

prototype PCB to fit into a tape

8bitMixTape newPCB.png


v0.5

now only on a PCB pseudo-smd... naaaiiice

8bit mixedTapev05.jpg


v0.5 zagreb edition


8bit Mix Tape - Zagreb Code


v0.6 lifepatch edition

Iyok is working on a simple programming interface, multiplatform, test the tunes on your computer, press upload and the baby is detected and whhoooosh, there you go!

we try to only rely on parts we can get in the local electronics store... which are nice and you can smoke inside!

Electronics shopping yogya.jpg

example codes

8-bit MixTape with button baby2

<syntaxhighlight lang="c">

/* PCrazy shit 8-bit symphony generator */ /* */

/*

* inspired by:
*  http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/

int speakerPin = 0; //int laserPin = 0; int buttonPin = 1; int potiPin3 = 2; int potiPin4 = 4;

int buttonState = 0; int lastButtonState = 0; int count = 0;

unsigned long int pulseWidthOFF = 0; unsigned long int pulseWidthON = 0; unsigned long int pulseWidthPart = 0;

int samplingDelay; unsigned long int reg;

long t = 0; int v = 0; unsigned int c3 = 0; unsigned int c4 = 4;

unsigned int analogValue;

void setup () {

 TCCR0B = TCCR0B & 0b11111001;
 
 pinMode (speakerPin, OUTPUT);
 pinMode(buttonPin, INPUT);
 digitalWrite(buttonPin, HIGH);
 pinMode (potiPin3, INPUT);
 pinMode (potiPin4, INPUT);
 reg = 0x551155aaL;

}


void loop () {

 // read the state of the switch into a local variable:
 buttonState = digitalRead(buttonPin);
 
 if (buttonState != lastButtonState && buttonState == HIGH) {
   // if the state has changed, increment the counter
     count++;
     t = 0; 
     delay(10000); 
     if (count > 5) {
       count = 0;
     } 
   
 } 
 
 lastButtonState = buttonState;
 
 

//count = 2;
switch(count) {
  
case 0: // a classic
    c4 = ((analogRead(potiPin4)>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = (t*(t>>8|t>>4))>>(t>>c4);
   analogWrite (speakerPin, v);
   
   delayMicroseconds(c3>>2);
   t++;

   break;
   
case 1: // ding dong

    c4 = ((1023-(analogRead(potiPin4))>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
    digitalWrite (speakerPin, v);
    
    delayMicroseconds(c3<<2);
    t++;

   break;
   
case 2: // experimental 8 bit

    c4 = ((1023-(analogRead(potiPin4))>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
    analogWrite (speakerPin, v);
    
    delayMicroseconds(c3);
    t++;

   break;
 
 
case 3: // PWM modulation

    c3 = (analogRead(potiPin3));
    c4 = (analogRead(potiPin4) + 1);


    pulseWidthPart++;
    
    pulseWidthON = (c3 * pulseWidthPart / 255);
    pulseWidthOFF = (c3 - pulseWidthON);
         
    digitalWrite(speakerPin, HIGH);
   
    delay(pulseWidthOFF);
    digitalWrite(speakerPin, LOW);  
     
    delay(pulseWidthON); 
   if (pulseWidthPart == 255) {
     pulseWidthPart = 254 - (c4>>3);
   }
    break;
   
case 4: //white noise

    unsigned long int newr;
    unsigned char lobit;
    unsigned char b31, b29, b25, b24;

    b31 = (reg & (1L << 31)) >> 31;
    b29 = (reg & (1L << 29)) >> 29;
    b25 = (reg & (1L << 25)) >> 25;
    b24 = (reg & (1L << 24)) >> 24;

   lobit = b31 ^ b29 ^ b25 ^ b24;

   newr = (reg << 1) | lobit;
  
   reg = newr;
 
   digitalWrite (speakerPin, reg & 1);
   
   samplingDelay = 1 + (2*(analogRead(potiPin3)>>0));

   delayMicroseconds (samplingDelay);
   
   break;
}

}

</syntaxhighlight>

What needs to be done

  • make a cool video
  • test the read/write head
  • define size and specifics of parts (small potentiometers anyone?)
  • design a PCB
  • make more cool songs

Schematics

see Babygnusbuino for the USB / attiny85 stuff

New pin definitions file: File:Pins arduino.h.zip put in ./sketchbook/hardware/Gnusbuino/variants/attiny85

// ATMEL ATTINY85 / BABYGNUSBUINO
//
//                        +---\/---+
//   !RESET (AD 0) PB5   1|        |8  VCC
//     (D3/A3)PWM? PB3   2|        |7  PB2 / USB+	
//     (D4/A2)PWM? PB4   3|        |6  PB1 / USB- / PWM?
//                  GND  4|        |5  PB0 / D0 / PWM
//                        +--------+
//
  • add 2 potentiometers on PB3 and PB4 (that's the pin 2 and pin 3 on the chip)
  • add 1 button to PB2 (pin 7), on press to 5V - maybe needs to be optimized and debounced
  • add speaker and mini-jack to PB0 (pin 5) and GND
  • add batteries incl. a on/off switch to VCC / GND
  • add 1 power indicator LED from VCC to ground after the switch
  • add 1 LED parallel to the speaker
  • optional - add a laser!

Parts

8bit MixTape parts.jpg

Babygnusbuino Parts:

  • 1 Atmel Attiny85 microprocessor (maybe u want to use a IC-socket)
  • 2 resistors 68 Ohms
  • 2 zeners 3.3V
  • 1 resistor 1k6
  • 1 capacitor 100n

8bit MixTape:

  • 1 potentiometer 20kOhm lin
  • 1 potentiometer 10kOhm log
  • 1 bushbutton (the flat ones that fit on a breadboard)
  • 1 mini Jack with switch, 3.5mm (mono in v0.2, stereo comes later)
  • 2 LEDs (smd or 5mm), including resistors as wished
  • 1 mini-speaker
  • 2 CR2032 batteries
  • 2 clips for batteries
  • 1 switch on/off
  • 1 mini-USB connector (u can also make your own USB cable, scavenging or get a USB plug)
  • (1 capacitor, 0.1 - 1µF for low-pass filter if needed)
  • (1 read/write head for magnetic tape)

Links

One Liners

http://youtube.com/watch?v=GtQdIYUtAHg

http://wurstcaptures.untergrund.net/music/

http://countercomplex.blogspot.com/2011/10/some-deep-analysis-of-one-line-music.html

http://wiki.sgmk-ssam.ch/index.php/Babygnusbuino

other sound projects with arduino / attiny

http://code.google.com/p/tinkerit/wiki/Auduino

Code

Basic

<syntaxhighlight lang="c"> /* PCrazy shit 8-bit symphony generator

  inspired by:
  http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/

int speakerPin = 0; int potiPin3 = A3; int potiPin4 = A2;

long t = 0; int v = 0; int c3 = 0; int c4 = 0;

void setup () {

 TCCR0B = TCCR0B & 0b11111001; //no timer pre-scaler, fast PWM
 
 pinMode (speakerPin, OUTPUT);
 pinMode (potiPin3, INPUT);
 pinMode (potiPin4, INPUT);

}


void loop () {

 c4 = ((analogRead(potiPin4)>>5) + 0); 
 c3 = (analogRead(potiPin3)>>0);
 v = (t*(t>>8|t>>4))>>(t>>c4);
 analogWrite (speakerPin, v);
 delayMicroseconds(c3>>3);
 t++;

}

</syntaxhighlight>

8bit MixTape with button selector

<syntaxhighlight lang="c">

/* Crazy shit 8-bit symphony generator */ /* */

/*

* inspired by:
*  http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*/

int speakerPin = 0; int buttonPin = 2; int potiPin3 = A3; int potiPin4 = A2;

int buttonState = 0; int lastButtonState = 0; int count = 0;

unsigned long int pulseWidthOFF = 0; unsigned long int pulseWidthON = 0; unsigned long int pulseWidthPart = 0;

int samplingDelay; unsigned long int reg;

long t = 0; int v = 0; unsigned int c3 = 0; unsigned int c4 = 0;

unsigned int analogValue;

void setup () {

 TCCR0B = TCCR0B & 0b11111001;
 
 pinMode (speakerPin, OUTPUT);
 pinMode(buttonPin, INPUT);
 pinMode (potiPin3, INPUT);
 pinMode (potiPin4, INPUT);
 reg = 0x551155aaL;

}


void loop () {

 // read the state of the switch into a local variable:
 buttonState = digitalRead(buttonPin);
 
 if (buttonState != lastButtonState && buttonState == HIGH) {
   // if the state has changed, increment the counter
     count++;
     t = 0; 
     delay(10000); 
     if (count > 5) {
       count = 0;
     } 
   
 } 
 
 lastButtonState = buttonState;

switch(count) {
  
case 0: // a classic
    c4 = ((analogRead(potiPin4)>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = (t*(t>>8|t>>4))>>(t>>c4);
   analogWrite (speakerPin, v);
   delayMicroseconds(c3>>2);
   t++;

   break;
   
case 1: // ding dong

    c4 = ((1023-(analogRead(potiPin4))>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
    digitalWrite (speakerPin, v);
    delayMicroseconds(c3<<2);
    t++;

   break;
   
case 2: // experimental 8 bit

    c4 = ((1023-(analogRead(potiPin4))>>6) + 1); 
    c3 = (analogRead(potiPin3)>>0);
    v = t * ((t>>15|t>>c4)&83&t>>(c4>>3));
    analogWrite (speakerPin, v);
    delayMicroseconds(c3);
    t++;

   break;
 
 
case 3: // PWM modulation

    c3 = (analogRead(potiPin3));
    c4 = (analogRead(potiPin4) + 1);


    pulseWidthPart++;
    
    pulseWidthON = (c3 * pulseWidthPart / 255);
    pulseWidthOFF = (c3 - pulseWidthON);
         
    digitalWrite(speakerPin, HIGH);
    delay(pulseWidthOFF);
    digitalWrite(speakerPin, LOW);  
    delay(pulseWidthON); 
   if (pulseWidthPart == 255) {
     pulseWidthPart = 254 - (c4>>3);
   }
    break;
   
case 4: //white noise

    unsigned long int newr;
    unsigned char lobit;
    unsigned char b31, b29, b25, b24;

    b31 = (reg & (1L << 31)) >> 31;
    b29 = (reg & (1L << 29)) >> 29;
    b25 = (reg & (1L << 25)) >> 25;
    b24 = (reg & (1L << 24)) >> 24;

   lobit = b31 ^ b29 ^ b25 ^ b24;

   newr = (reg << 1) | lobit;
  
   reg = newr;
 
   digitalWrite (speakerPin, reg & 1);
   samplingDelay = 1 + (2*(analogRead(potiPin3)>>0));

   delayMicroseconds (samplingDelay);
   
   break;
}

}

</syntaxhighlight>


8bit Mix Tape Advanced

Prototype using the Seeeduino 328, more pots, easier to program

<syntaxhighlight lang="c">

/* PCrazy shit 8-bit symphony generator */ /* */

/*

* inspired by:
*  http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-line-of.html
*
*  http://wurstcaptures.untergrund.net/music/
*
*/


int speakerPin = 10; int speakerPin2 = 11; int buttonPin = 2; int pot0 = 0; int pot1 = 1; int pot2 = 2; int pot3 = 3;

long t = 0;

unsigned int p0 = 10; unsigned int p1 = 4; unsigned int p2 = 4; unsigned int delta_T = 4;

int v = 0;

void setup () {

 TCCR0B = TCCR0B & 0b11111001; //no timer pre-scaler, fast PWM

 pinMode (speakerPin, OUTPUT);
 pinMode (speakerPin2, OUTPUT);
 pinMode(buttonPin, INPUT);
 digitalWrite(buttonPin, HIGH);
 pinMode (pot0, INPUT);
 pinMode (pot1, INPUT);
 pinMode (pot2, INPUT);
 pinMode (pot3, INPUT);


}

void loop () {

   //p0 = (analogRead(pot0)>>3);
   p1 = (analogRead(pot1)>>7);
   p2 = (analogRead(pot2)>>7);
   delta_T = (analogRead(pot3)>>0);


   //v = t * ((t>>15|t>>7)&p1&t>>(p2>>3));
   
   //v = t * ((t>>p1|t>>3)&17&t>>9);
   
   //v = (t|p1) * ((t>>p2|t>>11)&47&t>>3);
   
   //v = t>>4&1?t>>5:-t>>p1 ;
   
   v = (t|3) * ((t>>1|t>>p1)&47&t>>p2);
   
   //v = t*t/p1;
   analogWrite (speakerPin, v);
   digitalWrite (speakerPin2, v);
   delayMicroseconds(delta_T);
   t++;

}

</syntaxhighlight>


8bit MixTape Pro Advanced 2000 LCD-version cartridge

8bit MixTape Pro Advanced 2000 LCD-version cartridge.png


Advanced Mini LCD code

Check it on dusjagr's GitHub

git clone https://github.com/dusjagr/8bit_MixTape_advanced-2000

Advanced Mini VideoOut edition

Coming soon...