Fix sync problem

This commit is contained in:
2023-09-21 00:00:45 +03:00
parent ae82dcf013
commit ae7c9d8cb6
2 changed files with 6 additions and 4 deletions

View File

@ -295,10 +295,10 @@ export class SoundEvent extends AudibleEvent {
this.values.chord.forEach((obj: { [key: string]: number }) => { this.values.chord.forEach((obj: { [key: string]: number }) => {
const copy = { ...this.values }; const copy = { ...this.values };
copy.freq = obj.freq copy.freq = obj.freq
superdough(copy, 1 / 4, this.values.dur || 0.5); superdough(copy, this.values.dur*2, this.values.dur);
}); });
} else { } else {
superdough(this.values, 1 / 4, this.values.dur || 0.5); superdough(this.values, this.values.dur*2, this.values.dur);
} }
}; };
} }

View File

@ -134,8 +134,10 @@ export class Player extends Event {
}; };
sound(name: string) { sound(name: string) {
if (this.areWeThereYet()) { if (this.areWeThereYet()) {
const event = this.next() as Pitch | Chord | ZRest; const event = this.next() as Pitch | Chord | ZRest;
const noteLengthInSeconds = this.app.clock.convertPulseToSecond(event.duration*4*this.app.clock.ppqn);
if (event instanceof Pitch) { if (event instanceof Pitch) {
const obj = event.getExisting( const obj = event.getExisting(
"freq", "freq",
@ -145,7 +147,7 @@ export class Player extends Event {
"octave", "octave",
"parsedScale" "parsedScale"
); );
obj.dur = event.duration; obj.dur = noteLengthInSeconds;
return new SoundEvent(obj, this.app).sound(name); return new SoundEvent(obj, this.app).sound(name);
} else if (event instanceof Chord) { } else if (event instanceof Chord) {
const pitches = event.pitches.map((p) => { const pitches = event.pitches.map((p) => {
@ -158,7 +160,7 @@ export class Player extends Event {
"parsedScale" "parsedScale"
); );
}); });
return new SoundEvent({dur: event.duration}, this.app).chord(pitches).sound(name); return new SoundEvent({dur: noteLengthInSeconds}, this.app).chord(pitches).sound(name);
} else if (event instanceof ZRest) { } else if (event instanceof ZRest) {
return RestEvent.createRestProxy(event.duration, this.app); return RestEvent.createRestProxy(event.duration, this.app);
} }