Skip to content

Commit

Permalink
Fix the problem where loop directive is ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
okaxaki committed Dec 24, 2023
1 parent 575f8b1 commit 5750801
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.7.5 (2023/12/25)
- Fixed the problem where `loop` directive was ignored.

# 1.7.4 (2023/12/04)
- Fixed the problem when exporting MML for MSX-DOS where an extra `EOF` marker was added even if it already exists.
- Fixed the problem where the name specified by the meta `name` directive was not reflected when exporting MML without pre-compiling.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msxplay-js",
"version": "1.7.4",
"version": "1.7.5",
"description": "",
"type": "module",
"engines": {
Expand Down
17 changes: 9 additions & 8 deletions src/msxplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import KSS2WAV from "./kss2wav.js";
import { AudioPlayer } from "./audio-player.js";

export class MSXPlay {

static async initialize() {
return KSSPlay.initialize();
}
Expand All @@ -20,7 +19,7 @@ export class MSXPlay {
async toVGM(data, duration, loop, callback) {
const kss = new KSS(data);
const vgm = await kss.toVGMAsync({
duration: duration,
duration: duration,
callback: callback,
loop: loop,
});
Expand Down Expand Up @@ -58,10 +57,12 @@ export class MSXPlay {
return null;
}
if (this.kssplay.getFadeFlag() == 0) {
var loop = this.kssplay.getLoopCount();
var remains = this.maxPlayTime - currentTime;
if (this.loopCount <= loop || (this.fadeTime && remains <= this.fadeTime)) {
this.kssplay.fadeStart(this.fadeTime);
const currentLoop = this.kssplay.getLoopCount();
const remains = this.maxPlayTime - currentTime;
if (this.kssplay.getFadeFlag() == 0) {
if (this.loop <= currentLoop || (this.fadeTime && remains <= this.fadeTime)) {
this.kssplay.fadeStart(this.fadeTime);
}
}
}
return this.kssplay.calc(samples);
Expand All @@ -87,7 +88,7 @@ export class MSXPlay {

/**
* type DataOptions = {
* duration: number;
* duration: number;
* fade: number;
* gain: number;
* debug_mgs: boolean;
Expand All @@ -101,7 +102,7 @@ export class MSXPlay {

this.kss = kss;
this.song = song;
this.loopCount = options.loop || 2;
this.loop = options.loop || 2;
this.fadeTime = options.fade ?? options.fadeTime ?? 5000;

if (this.kssplay != null) {
Expand Down

0 comments on commit 5750801

Please sign in to comment.