@@ -7,19 +7,41 @@ var express = require('express'),
77 io = require ( 'socket.io' ) ( http ) ,
88 url = require ( 'url' ) ,
99 shell = require ( 'shelljs' ) ,
10- port = 3000 ;
10+
11+ port = 3000 ,
12+ chords = {
13+ 'C' : [ 'C3' , 'E3' , 'G3' ] ,
14+ 'Dm' : [ 'D3' , 'F3' , 'A3' ] ,
15+ 'Em' : [ 'E3' , 'G3' , 'B3' ] ,
16+ 'F' : [ 'F3' , 'A3' , 'C3' ] ,
17+ 'G' : [ 'G3' , 'B3' , 'D3' ] ,
18+ 'Am' : [ 'A3' , 'C3' , 'E3' ]
19+ } ;
1120
1221app . use ( '/static' , express . static ( __dirname + '/node_modules' ) ) ;
1322
1423app . get ( '/' , function ( req , res ) {
1524 res . sendFile ( __dirname + '/index.html' ) ;
1625} ) ;
1726
27+ app . get ( '/chords' , function ( req , res ) {
28+ res . sendFile ( __dirname + '/chords.html' ) ;
29+ } ) ;
30+
1831io . on ( 'connection' , function ( socket ) {
1932 console . log ( 'a user connected' ) ;
2033
2134 socket . on ( 'play' , function ( msg ) {
22- shell . exec ( 'play -qn synth 2 pluck ' + msg , { async : true } ) ;
35+ var command = 'play -qn synth 2 pluck ' + msg ;
36+
37+ shell . exec ( command , { async : true } ) ;
38+ } ) ;
39+
40+ socket . on ( 'chord' , function ( msg ) {
41+ var chord = chords [ msg ] ,
42+ command = 'play -qn synth sin ' + chord [ 0 ] + ' sin ' + chord [ 1 ] + ' sin ' + chord [ 2 ] + ' delay 0 .01 .02 remix - fade 0 2 .1 norm -1' ;
43+
44+ shell . exec ( command , { async : true } ) ;
2345 } ) ;
2446
2547 socket . on ( 'disconnect' , function ( ) {
0 commit comments