diff --git a/editor/EditorConfig.ts b/editor/EditorConfig.ts index 24d4a12e..8f8aa484 100644 --- a/editor/EditorConfig.ts +++ b/editor/EditorConfig.ts @@ -23,7 +23,7 @@ import {DictionaryArray, BeepBoxOption, InstrumentType, toNameMap} from "../synt } export class EditorConfig { - public static readonly version: string = "3.0.11"; + public static readonly version: string = "3.0.12"; public static readonly versionDisplayName: string = "BeepBox " + EditorConfig.version; public static readonly presetCategories: DictionaryArray = toNameMap([ diff --git a/editor/ExportPrompt.ts b/editor/ExportPrompt.ts index 3aaec529..51427d29 100644 --- a/editor/ExportPrompt.ts +++ b/editor/ExportPrompt.ts @@ -206,7 +206,7 @@ import {MidiChunkType, MidiFileFormat, MidiControlEventMessage, MidiEventType, M synth.nextBar(); } } - const sampleFrames: number = synth.getSamplesPerBar() * synth.getTotalBars(this._enableIntro.checked, this._enableOutro.checked); + const sampleFrames: number = Math.ceil(synth.getSamplesPerBar() * synth.getTotalBars(this._enableIntro.checked, this._enableOutro.checked)); const recordedSamplesL: Float32Array = new Float32Array(sampleFrames); const recordedSamplesR: Float32Array = new Float32Array(sampleFrames); //const timer: number = performance.now(); diff --git a/package.json b/package.json index 4361c383..65989a54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BeepBox", - "version": "3.0.11", + "version": "3.0.12", "description": "BeepBox is an online tool for sketching and sharing instrumental melodies.", "author": "John Nesky", "license": "MIT", diff --git a/synth/synth.ts b/synth/synth.ts index 6c79952d..0454516e 100644 --- a/synth/synth.ts +++ b/synth/synth.ts @@ -2462,7 +2462,7 @@ declare global { this.tick = Math.floor(remainder); const samplesPerTick: number = this.getSamplesPerTick(); remainder = samplesPerTick * (remainder - this.tick); - this.tickSampleCountdown = Math.floor(samplesPerTick - remainder); + this.tickSampleCountdown = samplesPerTick - remainder; } } @@ -2634,9 +2634,8 @@ declare global { let ended: boolean = false; // Check the bounds of the playhead: - if (this.tickSampleCountdown == 0 || this.tickSampleCountdown > samplesPerTick) { - this.tickSampleCountdown = samplesPerTick; - } + while (this.tickSampleCountdown <= 0) this.tickSampleCountdown += samplesPerTick; + if (this.tickSampleCountdown > samplesPerTick) this.tickSampleCountdown = samplesPerTick; if (playSong) { if (this.beat >= this.song.beatsPerBar) { this.bar++; @@ -2710,9 +2709,7 @@ declare global { while (bufferIndex < outputBufferLength && !ended) { const samplesLeftInBuffer: number = outputBufferLength - bufferIndex; - const runLength: number = (this.tickSampleCountdown <= samplesLeftInBuffer) - ? this.tickSampleCountdown - : samplesLeftInBuffer; + const runLength: number = Math.min(Math.ceil(this.tickSampleCountdown), samplesLeftInBuffer); for (let channel: number = 0; channel < this.song.getChannelCount(); channel++) { if (channel == this.liveInputChannel) { @@ -2880,7 +2877,7 @@ declare global { } this.tick++; - this.tickSampleCountdown = samplesPerTick; + this.tickSampleCountdown += samplesPerTick; if (this.tick == Config.ticksPerPart) { this.tick = 0; this.part++; @@ -4328,9 +4325,9 @@ declare global { if (this.song == null) return 0; const beatsPerMinute: number = this.song.getBeatsPerMinute(); const beatsPerSecond: number = beatsPerMinute / 60.0; - const partsPerSecond: number = beatsPerSecond * Config.partsPerBeat; - const tickPerSecond: number = partsPerSecond * Config.ticksPerPart; - return Math.floor(this.samplesPerSecond / tickPerSecond); + const partsPerSecond: number = Config.partsPerBeat * beatsPerSecond; + const tickPerSecond: number = Config.ticksPerPart * partsPerSecond; + return this.samplesPerSecond / tickPerSecond; } } diff --git a/tasks.txt b/tasks.txt index 3824e1f3..55e61600 100644 --- a/tasks.txt +++ b/tasks.txt @@ -353,4 +353,6 @@ √ Allow playing piano while song is paused, added preference to preview added notes while paused. √ Added preference to control whether to display song data in url. √ Added song recovery feature to file menu. -√ Added .mp3 file export. \ No newline at end of file +√ Added .mp3 file export. +√ Added tinyurl shortcut to file menu. +√ BPM is now precise.