- VueJS
- Vuex
- Webpack
- ESLint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const server = app.listen(app.get('PORT'), (error) => { | |
if (error) { | |
console.log('Server started with an error', error); | |
process.exit(1); | |
} | |
console.log(`Server started and is listening at http://localhost:${app.get('PORT')}`); | |
}); | |
const socket = new binaryServer({ | |
server: server, | |
path: '/socket', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new BinaryClient(location.origin.replace('http', 'ws').replace('https', 'ws') + '/socket'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stream.on('data', (data) => { | |
console.log(data); | |
const tone = data.readInt8(1); | |
Object.keys(socket.clients).map( | |
i => playTone(tone, socket.clients[i].createStream()) | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.on('open', function () { | |
MIDIStream = client.createStream(); | |
}); | |
client.on('stream', function (stream) { | |
stream.on('data', handleReceiveAudioData); | |
stream.on('end', handleEndAudioStream); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function playSound(audioBuffer) { | |
var source = context.createBufferSource(); | |
source.buffer = audioBuffer; | |
source.connect(context.destination); | |
source.start(0); | |
console.timeEnd('send'); | |
} | |
function handleMidiMessage(e) { | |
if (!MIDIStream || e.data[0] !== 0x90) return; | |
console.log(e); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const socket = new binaryServer({ | |
port: 3001, | |
}); | |
function playTone(tone, stream) { | |
if (tone > 61 || tone < 1) { | |
console.log('undefined tone', tone); | |
return; | |
} | |
const filePath = path.resolve(__dirname, 'wav', `${tone}.wav`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const binaryServer = require('binaryjs').BinaryServer; | |
const socket = new binaryServer({ | |
port: 3001, | |
}); | |
socket.on('connection', (client) => { | |
client.on('stream', (stream, meta) => { | |
stream.on('data', (data) => { | |
console.log(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleMidiMessage(e) { | |
console.log(e); | |
if (!MIDIStream || e.data[0] !== 0x90) return; | |
MIDIStream.write(e.data); | |
} |
NewerOlder