OSC + Loop machine + Makeymakey

Hi @robin.newman

Love the recent refactor, less duplication of code :slight_smile:

I had to modify the parsing function to

live_loop :pon do
  b = sync "/osc/sound/*"
  if b[0]==1
    r=parse_sync_address "/osc/sound/*"
    ns= r[2]#[4..-1]
    set ("c"+ns).to_sym,1
    doCommandSelect(ns .to_i)
  end
end
live_loop :poff do
  b = sync "/osc/sound/*"
  if b[0]==0
    r=parse_sync_address "/osc/sound/*"
    ns= r[2]#[4..-1]
    set ("c"+ns).to_sym,0
  end
end

And then it works for my OCS messages!

Looking good! FX is crazy

Putting right samples on it tonight!

thanks

Iā€™ve done one more update to enable switching on and off of the background pusling screen and the background pulse tones. Iā€™ve made a video on you tube showing the final project in action, and updated the code on teh gist site. see link on my last post above.

2 Likes

Hello

So I have patched the MakeyMakey to fit all 11 keys and that works great on MAC! However, on PI the sound is really really badā€¦ I have removed the nodejs script from PI and running it on Mac so its not the node so it seems Sonic PI 3.0.1 running on PI3 just does not have the power? How can I troubleshoot whatā€™s taking most resources?

Realtime is pretty much gone. and it can not keep up with timingā€¦ :frowning: Seem like I have to use bigger computerā€¦

P

Iā€™m currently looking at performance on a Pi3, which as you say is not good. I may be able to tweak things a bit, but it will not give the same performance as on a more powerful machine.

Also going to try it on a Pi3 B+ just released.

I have spent this evening looking at the program on a Pi3 and on a new Pi3 B+. I have produecd a version which is slightly less agressive on resources at the expsnes of a slightly longer response time and the loss of the gverb effects on the Mac version. I have left this on the background pulse which seems to work OK.

The main diference with the Pi3 B+ is that SP boots a little bit quicker, and it has a much faster WiFi connection, but I havenā€™t detected much change in performance in SP itself yet. I have added the Pi3 version to the gist. which is linked here

Hi, iā€™m using makey makey with sonic pi and processing, you can find the codes here for now, but iā€™m gonna write a more complete post soon.

1 Like

Thats awesome. I actually do a lot with Makey Makey and p5.js, the javascript version of processing. Unfortunately there arenā€™t as many libraries yet to do things with OSC, midi etc to have it interact with Sonic Pi but I am playing around with whatā€™s available. I love the idea of making reactive visual sketches in Processing or p5 that run with SPi.

Canā€™t wait to see more of what you are doing.

guess whatā€¦ surprise! i worked on getting this running in 2016 (throwback wednesday!) while wathcing all those dan shiffman coding rainbow videos. itā€™s heartbeat.js to get midi notes to p5.js. the tricky part was just where to load in the heartbeat stuff, so that it would work with p5ā€™s setup/draw functions. i think they changed something, something to do with promises maybe, cause when i initially opened it up again, it had stopped workingā€¦ but anyway, now itā€™s fixed. so you can have your midi events be recognized in a browser sketch, and go to town with all your javascript mayhem. enjoy!

<html>
<head>
  <meta charset="UTF-8">
  <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"></script>
	<script language="javascript" type="text/javascript" src="https://cdn.rawgit.com/abudaan/heartbeat/gh-pages/build/heartbeat.js"></script>
	

	<script>
var portname = "", 
    inputName = "", 
    midiEventData1 = 0, 
    midiEventData2 = 0;
		
window.onload = function(){
    var sequencer = window.sequencer;
    
	sequencer.ready(function init(){		
		var song = sequencer.createSong();
		
		sequencer.getMidiInputs(function(port){
			portname = port.name;
		});
		
		song.addMidiEventListener('note on', 'note off', function(midiEvent, input){
			inputName = input.name;
			midiEventData1 = midiEvent.data1;
			midiEventData2 = midiEvent.data2;
			
			console.log(midiEventData1);
		});
    });
};
	
	</script>
	
 <script>
 function preload(){
 }

function setup() {
  createCanvas(windowWidth,windowHeight);
  background(0);
  fill(255);
	
	text(portname,100,100);
} 

function draw() {
  clear()
  text(portname,100,100);
  text(midiEventData1,100,150);
}  

</script>
  <style>
  	* { margin:0; padding:0; } /* to remove the top and left whitespace */
	html, body { width:100%; height:100%; } /* just to be sure these are full screen*/
  	canvas {
	 outline: 0px;
	 position: absolute;
	 left: 0px;
	 top: 0px;
	 width: 100%;
	 height: 100%;

	 display:block;
	 background: #000011;
		}
	footer { 
			width: 175px; 
			height: 1.5em; 
			position: fixed; 
			bottom: 0;
			right: 0;
			padding: 3px 5px 5px 5px;
			text-align: left;
			z-index: 200;
		}
 </style>
</head>

<body>
	
</body>
</html> 
1 Like

Woah! This looks really cool. Thanks so much for sharing. I went to the examples on github and got the basic midi in and midi out talking to SPi. Iā€™ll see what I can do with p5 although Iā€™m not very experienced with Vanilla Javascript, mostly just the p5 API.

Should I just copy the code above into the html file of my p5 sketch or would I just put the part on top to load the library and put the rest in the sketch file?

hmmā€¦ actually, i havenā€™t kept up with what theyā€™ve added into p5.js lately, so maybe theyā€™ve added in WebMIDI, and you donā€™t even need thisā€¦ if you can find that then maybe this isnā€™t necessary, but if not, then just put this chunk in the head of your html file (or i guess anywhere before the p5 setup/draw functions, so that it gets loaded in, and the portname variable gets set before the p5 setup function is called)

<script language="javascript" type="text/javascript" src="https://cdn.rawgit.com/abudaan/heartbeat/gh-pages/build/heartbeat.js"></script>
<script>
var portname = "", 
    inputName = "", 
    midiEventData1 = 0, 
    midiEventData2 = 0;
		
window.onload = function(){
    var sequencer = window.sequencer;
    
	sequencer.ready(function init(){		
		var song = sequencer.createSong();
		
		sequencer.getMidiInputs(function(port){
			portname = port.name;
		});
		
		song.addMidiEventListener('note on', 'note off', function(midiEvent, input){
			inputName = input.name;
			midiEventData1 = midiEvent.data1;
			midiEventData2 = midiEvent.data2;
			
			console.log(midiEventData1);
		});
    });
};
</script>

actually, this was one of my first things off of the p5 api, trying to figure out some of the very confusing other aspects of how javascript worksā€¦ but i gotta say, for however frustrating it is, learning javascript is time well-spent!