Basic Information

This page allows you to fork a new project from an existing project (QuadBuzzer). The newly forked project will be listed in the IoT Projects page as a new entry. If you want to overwrite the existing project, please edit it instead.

* Photo URLs that end with any one of .jpg, .jpeg, .png or that are uploaded to the Gyazo web service in the PNG format (e.g.https://gyazo.com/hogehoge) are supported.

{ "dependencies": { "ws": "latest" } }

* Node.js entry point main: index.js and dependencies to the npm module dependencies: { f3js: (略) } will be automatically added and thus do not need to be in this form.

Card preview
QuadBuzzer
'24/10/26 5:3
Yet another musical instrument. Server-side impl is not yet public.

Private Project

Unchecking this will make the project public and be listed in the IoT Projects page. The checkbox is unchecked by default since we want you to share the projects! Additionally, you cannot check this unless you are logged in. Once you make the project public, it cannot be undone. (Any edits to the project except for forking will also be public.)

Source Code

Provide the source code of a microcontroller or tiny computer in JavaScript. Node.js-based computers are supported. Require f3js package and use its API to design the device enclosure.

var WebSocket = require('ws'); var serverAddr = 'ws://192.168.10.100:8080/entry'; // Server URL var ws = new WebSocket(serverAddr); var upmBuzzer = require('jsupm_buzzer'); var numBuzzers = 5; // Number of buzzers [1,5] var volume = 27; // Volume [0,100] var inputs = [3, 5, 6, 9]; var buzzers = []; var r = 80; var f3js = require('f3js'); var c = f3js.createContainer(); c.x = 50; c.y = 50; var c1 = 43 , c2 = 36 , x = 70 , y = 140 , width = 70; var a = c.createPath(); var ps = a.extrude(60); ps[0].y = 50; ps[0].x = 270; f3js.add(ps[0]); var dx = [ 65, 145, 65, -15] , dy = [-15, 65, 145, 65]; function addPetal(layout, module) { var cc = f3js.createContainer(); var pp = cc.createPath() .moveTo(-25, 10) .curveTo(-15, 30, 15, 30, 25, 10) .moveTo(-25, 10) .lineTo(-25 ,-5) .moveTo(25, 10) .lineTo(25 ,-5); // draw arc var thetaOffset = 25 / r; var theta = ((Math.PI * 2) - (thetaOffset * 2 * numBuzzers)) / numBuzzers; var n = 50; for (var j = 0; j <= n; j ++) { var t = thetaOffset + (theta / n) * j; pp.lineTo( Math.sin(t) * r, Math.cos(t) * r - r ); } if(module) { cc.add(module) cc.drawRectangle(15, -5, 5, 10); } c.add(cc, layout); } var circle = c.drawCircle(65, 65, r); circle.layout = 'distribute'; for (var i = 0; i < numBuzzers; i ++) { var buzzer = new upmBuzzer.Buzzer(inputs[i]); buzzer.setVolume(volume*0.01); buzzer.stopSound(); buzzer.stopSound(); buzzers.push(buzzer); addPetal(circle, buzzer) } circle = c.drawCircle(285, 65, r); circle.layout = 'distribute'; for (var i = 0; i < numBuzzers; i ++) { addPetal(circle) } var opposite = [], dh = 2; var pathl = c.jln(0, 40, 0, 90, 3, dh); pathl.internal = true; ps = pathl.extrude(60); ps[0].x = -40; ps[0].y = 180; c.add(ps[0]); opposite.push(ps[1]); var pathr = c.jln(130, 90, 130, 40, 3, dh); pathr.internal = true; ps = pathr.extrude(60); ps[0].x = 20; ps[0].y = 180; ps[0].drawRectangle(35, 60 - dh*2 - 5, 10, 3); ps[0].drawRectangle(5, 60 - dh*2 - 12, 15, 10); c.add(ps[0]); opposite.push(ps[1]); var patht = c.jln(100, 25, 30, 25, 3, dh); patht.internal = true; ps = patht.extrude(60); ps[0].x = 80; ps[0].y = 180; c.add(ps[0]); opposite.push(ps[1]); var pathb = c.jln(30, 105, 100, 105, 3, dh); pathb.internal = true; ps = pathb.extrude(60); ps[0].x = 160; ps[0].y = 180; c.add(ps[0]); opposite.push(ps[1]); for (var i = 0; i < 4; i ++) { opposite[i].x += 220; c.add(opposite[i]); } opposite[0].x += 130 + dh; opposite[1].x -= 130 + dh; /* var pathlc = c.createPath(); pathlc.moveTo(220, 40).dovetailTo(220, 85, 3, 1, false, false, true); var pathrc = c.createPath(); pathrc.moveTo(350, 40).dovetailTo(350, 90, 3, 1, false, false, true); var pathtc = c.createPath(); pathtc.moveTo(250, 25).dovetailTo(320, 25, 3, 1, false, false, true); var pathbc = c.createPath(); pathbc.moveTo(250, 100).dovetailTo(320, 100, 3, 1, false, false, true); */ ws.on('message', function(message) { if (mute) return; var data = JSON.parse(message); switch (data.message) { case 'note_on': if(buzzers[data.channel]) { buzzers[data.channel].setVolume(volume); buzzers[data.channel].playSound(1000000 / data.frequency, 0); } break; case 'note_off': if(buzzers[data.channel]) { buzzers[data.channel].stopSound(); buzzers[data.channel].stopSound(); } break; } }); var var64599 = 50.5; // *proposed* Test [1,100]
Customization

This content does not allow any customization.

Layout view options
Adding comments to variable declarations in the source code populate various GUI widgets in the "Customization" section depending on their types.

Design Alternatives

Modules

No modules are required for this project.

Layout
Program

Login first to use this feature.