Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noise channels at 4 and 5 #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The Play commands allows you to play synth notes.

#### Settings

The Settings commands allow you to change the sound of the synth. The settings command format is a **channel** value between `0-G`, a 3 characters long **name**, followed by four values between `0-G`. The possible waveforms are `si`, `2i`, `4i`, `8i`, `tr`, `2r`, `4r`, `8r`, `sq`, `2q`, `4q` `8q`, `sw`, `2w`, `4w` and `8w`.
The Settings commands allow you to change the sound of the synth. The settings command format is a **channel** value between `0-G`, a 3 characters long **name**, followed by four values between `0-G`. The possible waveforms are `si`, `2i`, `4i`, `8i`, `tr`, `2r`, `4r`, `8r`, `sq`, `2q`, `4q` `8q`, `sw`, `2w`, `4w` and `8w`, and for noise `wh`, `pi`, `br`.

| Command | Channel | Name | Info |
| :- | :- | :- | :- |
Expand Down
17 changes: 12 additions & 5 deletions desktop/sources/scripts/interface.channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const Tone = require('tone')
const OCTAVE = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B']
const MAJOR = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
const MINOR = ['c', 'd', 'F', 'f', 'g', 'a', 'C']
const WAVCODES = ['si', 'tr', 'sq', 'sw', '2i', '2r', '2q', '2w', '4i', '4r', '4q', '4w', '8i', '8r', '8q', '8w']
const WAVNAMES = ['sine', 'triangle', 'square', 'sawtooth', 'sine2', 'triangle2', 'square2', 'sawtooth2', 'sine4', 'triangle4', 'square4', 'sawtooth4', 'sine8', 'triangle8', 'square8', 'sawtooth8']
const WAVCODES = ['br', 'pi', 'wh', 'si', 'tr', 'sq', 'sw', '2i', '2r', '2q', '2w', '4i', '4r', '4q', '4w', '8i', '8r', '8q', '8w']
const WAVNAMES = ['brown', 'pink', 'white', 'sine', 'triangle', 'square', 'sawtooth', 'sine2', 'triangle2', 'square2', 'sawtooth2', 'sine4', 'triangle4', 'square4', 'sawtooth4', 'sine8', 'triangle8', 'square8', 'sawtooth8']

export default function ChannelInterface (pilot, id, node) {
Interface.call(this, pilot, id, node, true)
Expand Down Expand Up @@ -63,7 +63,11 @@ export default function ChannelInterface (pilot, id, node) {
if (this.lastNote && performance.now() - this.lastNote < 100) { return }
const name = `${data.note}${data.sharp}${data.octave}`
const length = clamp(data.length, 0.1, 0.9)
this.node.triggerAttackRelease(name, length, '+0', data.velocity)
if (this.node.noise) {
this.node.triggerAttackRelease(length, '+0', data.velocity)
} else {
this.node.triggerAttackRelease(name, length, '+0', data.velocity)
}
this.lastNote = performance.now()
}

Expand All @@ -87,6 +91,9 @@ export default function ChannelInterface (pilot, id, node) {
if (data.mod && this.node.modulation) {
this.node.modulation._oscillator.set('type', data.mod)
}
if (data.wav && this.node.noise && data.wav != 'sine') {
this.node.set('noise.type', data.wav)
}
this.lastOsc = performance.now()
this.updateOsc(data)
}
Expand All @@ -108,7 +115,8 @@ export default function ChannelInterface (pilot, id, node) {
this.updateOsc = function (data, force = false) {
if (pilot.animate !== true) { return }
if (force !== true && (!data || !data.isOsc)) { return }
setContent(this.osc_el, `${this.node.oscillator ? wavCode(this.node.oscillator._oscillator.type) : '--'}${this.node.modulation ? wavCode(this.node.modulation._oscillator.type) : '--'}`)
const oscCode = this.node.noise ? wavCode(this.node.noise._type) : (this.node.oscillator ? wavCode(this.node.oscillator._oscillator.type) : '--')
setContent(this.osc_el, `${oscCode}${this.node.modulation ? wavCode(this.node.modulation._oscillator.type) : '--'}`)
}

this.randEnv = function () {
Expand Down Expand Up @@ -149,7 +157,6 @@ export default function ChannelInterface (pilot, id, node) {
const velocity = msg.length >= 3 ? from16(msg.substr(2, 1)) : 0.66
const length = msg.length === 4 ? from16(msg.substr(3, 1)) : 0.1
const transposed = transpose(note, octave)
console.log(transposed)
return { isNote: true, octave: transposed.octave, note: transposed.note, sharp: isUpperCase(transposed.note) === false ? '#' : '', string: `${octave}${note}`, length: length, velocity: velocity }
}

Expand Down
12 changes: 7 additions & 5 deletions desktop/sources/scripts/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export default function Mixer (pilot) {
this.channels[1] = new ChannelInterface(pilot, 1, new Tone.AMSynth({ 'harmonicity': 1.5, 'oscillator': { 'type': 'triangle8' }, 'modulation': { 'type': 'sawtooth' } }))
this.channels[2] = new ChannelInterface(pilot, 2, new Tone.AMSynth({ 'harmonicity': 1.75, 'oscillator': { 'type': 'sawtooth8' }, 'modulation': { 'type': 'triangle' } }))
this.channels[3] = new ChannelInterface(pilot, 3, new Tone.AMSynth({ 'harmonicity': 2, 'oscillator': { 'type': 'square8' }, 'modulation': { 'type': 'square' } }))
// AM
this.channels[4] = new ChannelInterface(pilot, 4, new Tone.AMSynth({ 'harmonicity': 1.25, 'oscillator': { 'type': 'sine4' }, 'modulation': { 'type': 'square8' } }))
this.channels[5] = new ChannelInterface(pilot, 5, new Tone.AMSynth({ 'harmonicity': 1.5, 'oscillator': { 'type': 'triangle4' }, 'modulation': { 'type': 'sawtooth8' } }))

// Noise
this.channels[4] = new ChannelInterface(pilot, 4, new Tone.NoiseSynth({ 'type': 'white'}))
this.channels[5] = new ChannelInterface(pilot, 5, new Tone.NoiseSynth({ 'type': 'brown' }))

// FM
this.channels[6] = new ChannelInterface(pilot, 6, new Tone.FMSynth({ 'harmonicity': 1.75, 'modulationIndex': 10, 'oscillator': { 'type': 'sawtooth4' }, 'modulation': { 'type': 'triangle8' } }))
this.channels[7] = new ChannelInterface(pilot, 7, new Tone.FMSynth({ 'harmonicity': 2, 'modulationIndex': 20, 'oscillator': { 'type': 'square4' }, 'modulation': { 'type': 'sine8' } }))
// FM
this.channels[8] = new ChannelInterface(pilot, 8, new Tone.FMSynth({ 'harmonicity': 0.5, 'modulationIndex': 30, 'oscillator': { 'type': 'sine' }, 'modulation': { 'type': 'sawtooth4' } }))
this.channels[9] = new ChannelInterface(pilot, 9, new Tone.FMSynth({ 'harmonicity': 2.5, 'modulationIndex': 40, 'oscillator': { 'type': 'sine' }, 'modulation': { 'type': 'triangle8' } }))
this.channels[10] = new ChannelInterface(pilot, 10, new Tone.MonoSynth({ 'volume': -20, oscillator: { 'type': 'sawtooth4' } }))
Expand Down Expand Up @@ -171,7 +173,7 @@ export default function Mixer (pilot) {
})
}
// Return to Osc Presets
this.run('0OSC8ISI;1OSC8RSW;2OSC8WTR;3OSC8QSQ;4OSC4I8Q;5OSC4R8W;6OSCTR8R;7OSCTR8I;8OSCTR4W;9OSCTR8R;AOSC4W--;BOSC4I--;COSCSI--;DOSCSW--;EOSCTR--;FOSCSQ--')
this.run('0OSC8ISI;1OSC8RSW;2OSC8WTR;3OSC8QSQ;4OSCWH--;5OSCBR--;6OSCTR8R;7OSCTR8I;8OSCTR4W;9OSCTR8R;AOSC4W--;BOSC4I--;COSCSI--;DOSCSW--;EOSCTR--;FOSCSQ--')
// Return to Effects Presets
this.run('BIT07;DIS00;WAH0F;CHE07;FEE00;TRE07;REV00;PHA0F;VIB01;CHO07')
}
Expand Down