Skip to content

Commit 7c510cd

Browse files
authored
Merge pull request #8 from bgins/release-0.4.2
Release 0.4.2
2 parents 29e6e02 + cc83dae commit 7c510cd

11 files changed

Lines changed: 197 additions & 164 deletions

File tree

package-lock.json

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moon-forge",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "A forge for lunar instruments",
55
"scripts": {
66
"start": "npm install && npm run build:dev && npm run dev",
@@ -37,7 +37,7 @@
3737
"watcherGlob": "**"
3838
},
3939
"dependencies": {
40-
"mousetrap-ts": "^1.0.0",
40+
"rxjs": "^6.6.3",
4141
"standardized-audio-context": "^25.1.3",
4242
"webmidi": "^2.5.1",
4343
"webnative": "^0.20.3"

src/Pages/Luna.elm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ init shared { params } =
7474
Encode.object
7575
[ ( "instrument", Instrument.encode Luna )
7676
, ( "patch", Patch.encode Patch.init )
77+
, ( "controller", Controller.encode Keyboard )
7778
]
7879
]
7980
)

src/Pages/Top.elm

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ view { params } =
4848
, Font.family Fonts.cinzel
4949
, Font.size 36
5050
]
51-
[ text "On a Far Off Planet" ]
51+
[ text "A Song of Moons" ]
5252
, paragraph
5353
[ Font.family Fonts.quattrocento
5454
, Font.size 20
@@ -143,7 +143,8 @@ view { params } =
143143
[ Font.family Fonts.quattrocento
144144
, Font.size 20
145145
]
146-
[ newTabLink
146+
[ text "We use "
147+
, newTabLink
147148
[ Font.color Colors.lightPurple
148149
, Font.bold
149150
, Border.widthEach { top = 0, right = 0, bottom = 1, left = 0 }
@@ -152,10 +153,10 @@ view { params } =
152153
[ Border.color Colors.lightPurple
153154
]
154155
]
155-
{ url = "https://guide.fission.codes/accounts", label = text "Fission" }
156+
{ url = "https://fission.codes", label = text "Fission" }
156157
, text
157158
"""
158-
provides us account and storage services. If you
159+
account and storage services. If you
159160
want to save your creations, we will ask you to "Store with
160161
Fission". A few things you should know about that:
161162
"""
@@ -189,7 +190,7 @@ view { params } =
189190
Fission will ask you to set up an account and link a
190191
second device. We highly recommend you set up a second
191192
device to prevent data loss. Because we do not store
192-
your data on a server, this is on you.
193+
your data on a server, we cannot recover it.
193194
"""
194195
]
195196
]
@@ -209,6 +210,26 @@ view { params } =
209210
"""
210211
]
211212
]
213+
, paragraph
214+
[ Font.family Fonts.quattrocento
215+
, Font.size 20
216+
]
217+
[ text "Please see the "
218+
, newTabLink
219+
[ Font.color Colors.lightPurple
220+
, Font.bold
221+
, Border.widthEach { top = 0, right = 0, bottom = 1, left = 0 }
222+
, Border.color Colors.darkGrey
223+
, mouseOver
224+
[ Border.color Colors.lightPurple
225+
]
226+
]
227+
{ url = "https://guide.fission.codes/accounts", label = text "Fission accounts guide" }
228+
, text
229+
"""
230+
for more information on your Fission account.
231+
"""
232+
]
212233
]
213234
]
214235
]

src/audio/audio.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Envelope } from './env-gen';
44
interface IInstrument {
55
playNote: (midiNote: number) => void;
66
stopNote: (midiNote: number) => void;
7+
stopAllNotes: () => void;
78
}
89

910
interface INote {

src/audio/env-gen.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Envelope {
7373
this.valueAtGateClose =
7474
this.settings.initialLevel +
7575
(this.settings.attackFinalLevel - this.settings.initialLevel) *
76-
((gateClosedAt - this.gateOpenAt) / this.settings.attackTime);
76+
((gateClosedAt - this.gateOpenAt) / this.settings.attackTime);
7777
} else if (gateClosedAt >= this.startDecayAt && gateClosedAt < this.startSustainAt) {
7878
this.valueAtGateClose =
7979
this.settings.attackFinalLevel *
@@ -105,10 +105,8 @@ class Envelope {
105105
// reschedule, but this is not done here yet
106106
if (this.gateOpen) {
107107
if (retriggerAt < this.startDecayAt) {
108-
console.log('retrigger in attack phase');
108+
// console.log('retrigger in attack phase');
109109
} else if (retriggerAt >= this.startDecayAt && retriggerAt < this.startSustainAt) {
110-
console.log('retrigger in decay phase');
111-
112110
const currentValue =
113111
this.settings.attackFinalLevel *
114112
Math.pow(
@@ -118,13 +116,10 @@ class Envelope {
118116

119117
this.reschedule(retriggerAt, currentValue, newSettings);
120118
} else {
121-
console.log('retrigger in sustain phase');
122119
this.reschedule(retriggerAt, this.settings.sustainLevel, newSettings);
123120
}
124121
} else {
125122
if (retriggerAt > this.gateClosedAt && retriggerAt <= this.gateClosedAt + this.settings.releaseTime) {
126-
console.log('retrigger in release phase');
127-
128123
const currentValue =
129124
this.valueAtGateClose *
130125
Math.pow(
@@ -136,7 +131,7 @@ class Envelope {
136131
this.gateOpen = true;
137132
this.endAt = Infinity;
138133
} else {
139-
console.log('retrigger after envelope completed');
134+
// console.log('retrigger after envelope completed');
140135
}
141136
}
142137
}
@@ -147,8 +142,6 @@ class Envelope {
147142
* We calculate the time when the attack would have started to get the right ramps.
148143
*/
149144
private reschedule(retriggerAt: number, currentValue: number, newSettings: IEnvelopeOptions): void {
150-
console.log('rescheduling');
151-
152145
// this.targetParam.cancelAndHoldAtTime(retriggerAt);
153146
this.targetParam.cancelScheduledValues(retriggerAt);
154147
this.targetParam.setValueAtTime(currentValue, retriggerAt);

src/audio/luna.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class Luna implements IInstrument {
3333
* Construct a new instance of Luna from flags and defaults
3434
*/
3535
constructor(flags: any) {
36-
console.log('New Luna', flags);
3736
this.oscillatorOptions = {
3837
type: flags.oscillator,
3938
detune: 0,
@@ -300,16 +299,24 @@ class Luna implements IInstrument {
300299
* and we may receive a retrigger from the user.
301300
*/
302301
stopNote(midiNote: number): void {
303-
const oscillator = this.notes[midiNote].oscillator;
304-
const ampEnv = this.notes[midiNote].ampEnv;
305-
const filterEnv = this.notes[midiNote].filterEnv;
302+
if (this.notes[midiNote]) {
303+
const oscillator = this.notes[midiNote].oscillator;
304+
const ampEnv = this.notes[midiNote].ampEnv;
305+
const filterEnv = this.notes[midiNote].filterEnv;
306306

307-
const now = this.audioContext.currentTime;
308-
ampEnv.closeGate(now);
309-
filterEnv.closeGate(now);
307+
const now = this.audioContext.currentTime;
308+
ampEnv.closeGate(now);
309+
filterEnv.closeGate(now);
310+
311+
const stopAt = ampEnv.getEndTime();
312+
oscillator.stop(stopAt);
313+
}
314+
}
310315

311-
const stopAt = ampEnv.getEndTime();
312-
oscillator.stop(stopAt);
316+
stopAllNotes(): void {
317+
Object.keys(this.notes).forEach(midiNote => {
318+
this.stopNote(+midiNote);
319+
});
313320
}
314321
}
315322

0 commit comments

Comments
 (0)