Things used in this project

Hardware components:
Intel.web.720.405
Intel Edison
×1
13045 01
SparkFun Block for Intel® Edison - Base
Or you could use the Intel breakout for the Edison
×1
Adafruit industries ada592 image 75px
USB-A to Micro-USB Cable
×1
SparkFun USB OTG Micro
×1
Software apps and online services:
Processing
Intel Edison Yocto Linux
PuTTY
Hand tools and fabrication machines:
Novation Launchpad S

Code

Processing CodeJava
The processing code that runs on the computer playing the music
import ddf.minim.*;
import ddf.minim.analysis.*;
import processing.opengl.*;

import processing.net.*; 

AudioInput stream;
FFT fft;

String url = "192.168.0.107:3000";
Client myClient;

boolean showGraphics = true;

int windowSize = 200;

int GridSize = 8;

int blockSize = windowSize / GridSize;

color red = color(255, 0, 0);
color green = color(0, 255, 0);
color yellow = color(255, 255, 0);


int[][] pads = {{ 0, 0, 0, 0, 0, 0, 0, 0 }, 
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0 }};

void setup(){
  if(showGraphics){
    size(windowSize,windowSize);
    colorMode(HSB, width, 100, width);
    noStroke();
    background(100,100,100);
  }
  Minim minim  = new Minim(this);
  stream = minim.getLineIn(Minim.STEREO);
  fft = new FFT(stream.bufferSize(), stream.sampleRate());
  
  println("Avaliable Spectrum Size: " + fft.specSize());
  
  myClient = new Client(this, "192.168.0.107", 3000);
}

void draw(){
   pads = new int[][] {{ 0, 0, 0, 0, 0, 0, 0, 0 }, 
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0 }};
  
 if(showGraphics){ 
   background(100, 100, 100);
  }
  fft.forward(stream.mix);
  pushMatrix();
  for(int i = 0; i < GridSize; i=i+1)
  {
    int barHeight = Math.round(fft.getBand(i*10)*4)/8;
    if(barHeight > GridSize){
      barHeight = GridSize;
    }
    for(int i2 = 0; i2 < barHeight; i2=i2+1)
    {  
      int barX = i * blockSize;
      if(i2 > 5){
        fill(red);
        pads[i][i2] = 3;
      }else if(i2 > 2){
        fill(yellow);
        pads[i][i2] = 2;
      }else{
        fill(green);
        pads[i][i2] = 1;
      }
      rect(barX, (height-(blockSize*i2))-blockSize, blockSize, blockSize);
    } 
  }
  popMatrix();
  sendServerData();
  delay(80);
}

void stop(){
  stream.close();
  myClient.stop();
  super.stop();
}

void sendServerData (){
  String padData = "";
  for(int[] ia :  pads){
    for(int i :  ia){
      padData = padData + Integer.toString(i) + " ";
    }
  }
  sendToServer(padData);
}

void sendToServer(String s){
  myClient.write("POST / HTTP/1.1\n");
  myClient.write("Host: 192.168.0.107:3000\n");
  myClient.write("Cache-Control: no-cache\n");
  myClient.write("Content-Type: text/plain\n");
  myClient.write("content-length: " + s.length() + "\n");     
  myClient.write("\n");
  myClient.write(s);
  myClient.write("\n\n");
}
NodeJS codeJavaScript
The code for running the NodeJS server, to start it simply type "node ." after creating the Node project
var express = require('express');
var app = express();
var bodyParser = require('body-parser')

var logging = false

//Novation Programmers Referance
//https://d19ulaff0trnck.cloudfront.net/sites/default/files/novation/downloads/4700/launchpad-s-prm.pdf

var colors = {"off":"0C", 
              "dim_green":"3E", "med_green":"3D", "full_green":"3C",
              "dim_red":"0D",   "full_red":"0F",
              "full_orange":"2F",
              "full_amber":"3F",
              "full_yellow":"3E"}

var novation_id = "00 20 29"
var launchpad_id = "20 00"

var commands = {"reset":"B0 00 00",
                "all_on":          "B0 00 7F",
                "button_layout_1": "B0 00 01",
                "button_layout_2": "B0 00 02",
                "device_inquiry":  "F0 7E 7F 06 01 F7",
                "empty_scroll":    "F0 00 20 29 00 F7",
                "switch_buffers":  "B0 10 "}

var buffer_bits = {"s":"20",    // display and write one buffer
                   "b0":"24",   // display 0 write 1
                   "b1":"21",   // display 1 write 0
                   "b0c":"34",  // display 0 copy to 1
                   "b1c":"31",  // display 1 copy to 0
                   "flash":"28" // write 0 swap every 280 ms
                  }


var displayGrid = ["0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C",
                   "0C","0C","0C","0C","0C","0C","0C","0C"]

app.use( bodyParser.text());

app.post('/', function(req, res) {
    process_data(req.body);
});

app.listen(3000, function () {
  run_cmd("amidi", ["-l"], function(text) { console.log (text) })
  reset_pad ()

  console.log('Example app listening on port 3000!');
})

function process_data (data){
    switch_buffers();
    var splitData = data.split(" ");
    var arrayLength = splitData.length; 
    for (var i = 0; i < arrayLength; i++) {
        if(parseInt(splitData[i]) == 0)
            displayGrid[i] = colors["off"]
        if(parseInt(splitData[i]) == 1)
            displayGrid[i] = colors["full_green"]
        if(parseInt(splitData[i]) == 2)
            displayGrid[i] = colors["full_yellow"]
        if(parseInt(splitData[i]) == 3)
            displayGrid[i] = colors["full_red"]
    }
    push_grid ();
}

var buffer = 0

function switch_buffers(){
    if(buffer = 0)
        buffer = 1
    else if (buffer = 1)
        buffer = 0
      run_cmd("amidi", ["-phw:2", "-S "+commands["switch_buffers"]+buffer_bits["b"+buffer]])
}

function reset_pad (){
    run_cmd("amidi", ["-phw:2", "-S "+commands["reset"]])
}

function push_grid (){
    var gridCommand = "92 ";
    var arrayLength = displayGrid.length;
    for (var i = 0; i < arrayLength; i++) {
        gridCommand = gridCommand + displayGrid[i] + " ";
    }

    run_cmd("amidi", ["-S " + gridCommand])
    if(logging)
       console.log("amidi -S " + gridCommand);
}

function run_cmd(cmd, args, callBack) {
    var spawn = require('child_process').spawn;
    var child = spawn(cmd, args);
    var resp = "";

     child.stdout.on('data', function (buffer) { resp += buffer.toString() });
     child.stderr.on('data', function (buffer) { resp += buffer.toString() });
     if(typeof callBack !== 'undefined')
         child.stdout.on('end', function() { callBack (resp) });

     if(logging){
        child.on('close', function (code){
          console.log('child process exited with code ' + code);
        });
        child.on('error', function (error){
          console.log('child process errored ' + error);
        });
    }
}

Credits

1473112518 0278dca0a01648e68b5d157cd8a8b98c%20small
Keith Mitchell

16 year old Canadian Professional Programmer and technology enthusiast

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

GO2
Advanced
  • 62
  • 3

Work in progress

We found an app that will look into the weather and gives you the best manner to go to school or work.

Arduino Wireless Weather Station
Advanced
  • 7,254
  • 31

Full instructions

In this tutorial I am going to show you how to build a Wireless Weather Station with a big 3.2" Color TFT display using Arduino.

Virtual Arduino Tennis
Advanced
  • 574
  • 4

Full instructions

Play tennis on a Neopixel matrix and an accelerometer with an Arduino! It's like Mario Tennis meets makers!

Pool Fill Control
Advanced
  • 2,383
  • 22

Work in progress

A system to monitor my pool sensors and refill my pool when necessary. Monitors water level & temp, pH, ORP, and power consumption.

Voice-Controlled Robot - Google Cloud Services
Advanced
  • 4,101
  • 18

Full instructions

Build a voice-controlled Arduino robot. You will use your own Android phone (powered by Google Cloud Services) to control it. Lots of fun!

Raspberry Pi Remote Control Car Camera
Advanced
  • 205
  • 3

Full instructions

This project will make a remote control car which has a view via an attached camera.

ProjectsCommunitiesContestsLiveJobsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback