arduiNoise(beats);

Bit-music loving Arduino users - I ported (and modded a bit) one of the Noise Toy programs over to the lovely and talented Arduino platform. Just add a couple of momentary switches to pins 8 and 9 and connect stereo audio to 3 and 4 - you're done. Loud Objects' code proved quite fun to tinker/learn with - if you're curious, try experimenting with different tempo values.

Read on to view and download-o the code-uino.

Makershedsmall
noisetoy_kit_crop.jpg
Loud Objects Noise Toy kit

Arduino Crop
Arduino Diecimila

/* Stereo BeatGen v1 - originally written by Loud Objects for the ATTiny85/NOISE TOY projects loudobjects.com - adapted/messed with for Arduino by Collin Cunningham me [at] collinmel.com assumes pins 3 & 4 connected to left & right audio momentary switches between 8 & 9 and GND */

unsigned long NextRandom = 1;
unsigned long Bass_Start = 300, Bass_End = 600;
unsigned char Last_Val_Left = 1, Last_Val_Right = 1;
unsigned long Bass_Left_Period = Bass_Start, Bass_Right_Period = Bass_Start;
unsigned long Bass_Left_Sample = 1, Bass_Right_Sample = 1;
unsigned char Bass_Left_On = 1, Bass_Right_On = 1;
unsigned char Snare_Left_On = 1, Snare_Right_On = 1;
unsigned char Snare_Left_Sample = 1, Snare_Right_Sample = 1;
unsigned long Tempo_Period = 1200, Tempo_Outer = 1, Tempo_Sample = 1;
unsigned char Trax_Left[] = {
1, 2, 3, 0, 3, 2, 0, 1};
unsigned char Trax_Right[] = {
2, 1, 0, 3, 1, 3, 0, 2};
unsigned char Track_Index = -1;
unsigned long New_Rand = randomGen();
unsigned long NextRandom2 = 1;
unsigned long Snare_Length = 500;

void setup()
{
// SET PINS 3 AND 4 AS OUTPUTS
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(2, INPUT);

// SET PULL-UP RESISTORS ON PINS 9 AND 8
pinMode(9, INPUT);
pinMode(8, INPUT);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(5, LOW);

}

void loop(){


NextRandom2 = NextRandom2 + 9;
New_Rand = NextRandom2;

// UPDATE SAMPLES
if (Bass_Left_On)
{
if (!(--Bass_Left_Sample))
{
if ((Bass_Left_Period += 11) > Bass_End)
{
Bass_Left_On = 0;
}
Bass_Left_Sample = Bass_Left_Period;
Last_Val_Left = 1 - Last_Val_Left;
}
}


if (Bass_Right_On)
{
if (!(--Bass_Right_Sample))
{
if ((Bass_Right_Period += 13) > Bass_End)
{
Bass_Right_On = 0;
}
Bass_Right_Sample = Bass_Right_Period;
Last_Val_Right = 1 - Last_Val_Right;
}
}


if (Snare_Left_On)
{
if (!(--Snare_Left_Sample))
{
Snare_Left_Sample = New_Rand / 200;// % 10;
Last_Val_Left = 1 - Last_Val_Left;
}
if (!(--Snare_Length))
{
Snare_Left_On = 0;
}
}


if (Snare_Right_On)
{
if (!(--Snare_Right_Sample))
{
Snare_Right_Sample = New_Rand / 200;// % 10;
Last_Val_Right = 1 - Last_Val_Right;
}
if (!(--Snare_Length))
{
Snare_Right_On = 0;
}
}

// CHECK FOR NEXT BEAT
if (!(--Tempo_Outer))
{
Tempo_Outer = 10;
if (!(--Tempo_Sample))
{
if (++Track_Index == 8)
Track_Index = 0;

Tempo_Sample = Tempo_Period;
Bass_Left_On = (Trax_Left[Track_Index] & 1);
Bass_Right_On = (Trax_Right[Track_Index] & 1);
Snare_Left_On = (Trax_Left[Track_Index] & 2);
Snare_Right_On = (Trax_Right[Track_Index] & 2);
Snare_Length = 5000;
Bass_Left_Period = Bass_Start;
Bass_Left_Sample = 1;
Bass_Right_Period = Bass_Start;
Bass_Right_Sample = 1;
}
}

// OUTPUT
if (Last_Val_Left)
PORTD |= (1 << 3);
else
PORTD &= ~((1 << 3));
if (Last_Val_Right)
PORTD |= (1 << 4);
else
PORTD &= ~((1 << 4));


// BUTTON INPUT CHECKS
//pin 8 for tempo
if ((digitalRead(8)) == LOW)
{
randomSeed(analogRead(0));
Tempo_Period = (random(1627) / 15 * 25); // experiment with diff values for better range
}
//pin 9 for beat
if (digitalRead(9) == LOW)
{
unsigned char i;
for (i = 0; i < 8; i++)
{
Trax_Left[i] = randomGen();
Trax_Right[i] = randomGen();
}
}
}

unsigned long randomGen(void) //pseudo random from original sketch
{
NextRandom = NextRandom * 3865 + 131;
return ((NextRandom >> 16) & 32767);
}


Recent Entries

Comments

Oldest comments listed first.

Posted by: VanessaC on August 29, 2008 at 12:37 PM

Awesome project, found an Arduino Synth here

Hey, seems like a great project, very straightforward which is nice, its not too complicated to get started with! I found a great project here that's similar, called the Arduino Synth: http://halfmachine.dk/posts/171

They say "We would like to make it possible to make installations which emits sounds and music without the need to have a computer connected. We needed to create a stand alone sound creation device which could be controlled by real time user input." ... "potentiometers are used to control the individual properties of each wave generator. In this way, sound can be controlled manually while playing music."

Thanks for the post, nice work!

Vanessa


Posted by: Collin Cunningham on September 2, 2008 at 7:04 PM

@VanessaC - Nice find! Glad you enjoyed the post.


Leave a comment


Subscribe to MAKE!Subscribe to MAKE Magazine!

Subscribe today, save 42% and get web access to MAKE free. MAKE Digital Edition is available only to subscribers.

$34.95 / 1 year
(4 Quarterly Issues)

Subscribe now


Void your warranty, violate a user agreement, fry a circuit, blow a fuse, poke an eye out. Make: The risk-takers, the doers, the makers of things... Welcome to Make: Online!


CRAFT Maker Shed Maker Faire MAKE television




Check out more videos from MAKE.

Maker SHED

Connect with MAKE

Be a MAKE fan on Facebook MAKE on Facebook
Visit our Facebook page and become a fan of MAKE!
MAKE on Twitter MAKE on Twitter
Follow our MAKE tweets!
MAKE Flickr Pool MAKE on Flickr
Join our MAKE Flickr Pool!
    make_tips on Twitter



    MAKE Archives

    Make: Money

    Make: Science Room
    Subscribe to MAKE Magazine!

    Make: Online editors and authors!

    Gareth BranwynGareth Branwyn
    Editor-in-Chief


    Phillip TorronePhillip Torrone
    Senior Editor
    | Web | Twitter


    Becky SternBecky Stern
    Associate Editor
    | AIM | Twitter


    Marc de VinckMarc de Vinck
    Contributing Writer
    | AIM | Twitter


    John ParkJohn Park
    Contributing Writer
    | Twitter


    Sean RaganSean Ragan
    Contributing Writer
    | Twitter


    Matt MetsMatt Mets
    Contributing Writer
    | AIM | Twitter


    Dale DoughertyDale Dougherty
    Editor & Publisher
    | Twitter


    Shawn ConnallyShawn Connally
    Managing Editor
    | Twitter


    Goli MohammadiGoli Mohammadi
    Associate Managing Editor

    Kip KayKip Kay
    Weekend Projects
    | AIM | Twitter


    Collin CunninghamCollin Cunningham
    Contributing Writer
    | AIM | Twitter

    Adam FlahertyAdam Flaherty
    Contributing Writer
    | AIM | Twitter


    John BaichtalJohn Baichtal
    Contributing Writer
    | AIM | Twitter



    More contributors: Mark Frauenfelder (Editor-in-Chief, MAKE magazine), Kipp Bradford (Technical Consultant/Writer), Chris Connors (Education), Diana Eng (Guest Author), Peter Horvath (Intern), Brian Jepson (O'Reilly Media), Robert Bruce Thompson (Science Room)

    Suggest a Site!

    Advertise here with FM.

    Why advertise on MAKE?
    Read what folks are saying about us!

    Click here to advertise on MAKE!



    Current Podcast

    itunesdl.gif Behind the Scenes at MAKE and CRAFT In January, many of the remote MAKE/CRAFT team members (myself included) convened at the Maker Media headquarters at O'Reilly Media in Sebastopol, California. Take a look behind the scenes of your favorite DIY publications as Goli Mohammadi gives us... More...

    Get the Make: Online sent via email
    Enter your email to receive Make: Online each day:



    Sign up for the Make: Newsletter

    Our Make: Newsletter covers news from maker Media, has original columns, Shed deals, and more! You can also read the archives of past issues.


     



    MAKE Fascination video series brought to you by Dow

    Make: Education
    MAKE: en EspaƱol MAKE: Japan
    Important please read


    Subscribe to MAKE Magazine!

    Recent Posts from the Craft: Blog