Skip to content

Commit

Permalink
prog
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisheng Jiang committed Dec 23, 2023
1 parent c6e7d5b commit bff9a1c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 28 deletions.
Binary file added a.out
Binary file not shown.
11 changes: 5 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@
<script src="https://kit.fontawesome.com/d43066eba1.js" crossorigin="anonymous"></script>

<script src="dist/sequence.js"></script>
<link href="fontawesome/css/all.min.css" rel="stylesheet" />
</head>

<body class="sans-serif space-between" style="height:auto !important">
<header>
<i class="fa-regular fa-user"></i>
<select id="sf2select" aria-placeholder="dafds">
<option>Select SF2 File</option>
</select>
</select>
<span id="midilist"></span>
<span id="ctrls"> </span>
<span id="ctrls"> </span>
<input type="file" tabindex="0" value="send file" id="file-btn" accept=".mid" />
<div id="ch_ctrl_bar"></div>
<div id="ch_ctrl_bar"></div>
</header>
<section> <span id="sequenceroot"></span>
<section> <span id="sequenceroot"></span>
</section>
<div id="channelContainer"></div>

Expand Down Expand Up @@ -59,4 +58,4 @@
</svg></template>
</body>

</html>
</html>
Binary file modified spin/spin.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion spin/spin.wasm.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions spin/src/sf2r/pdyml.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ int main(int argc, char **args) {
sprintf(str, "cshf/%s.txt", basename((char *)filename));
printf("\n%s", str);

// freopen(str, "w+", stdout);

sheader_t *header = (sheader_t *)malloc(sizeof(sheader_t));
header2_t *h2 = (header2_t *)malloc(sizeof(header2_t));
fread(header, sizeof(sheader_t), 1, fd);
Expand Down
2 changes: 1 addition & 1 deletion spin/src/spin.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void advanceStage(EG* eg) {
int stepsFull =
timecent2sample(eg->release); //+ timecent2sample(eg->decay);
eg->egIncrement = -eg->sustain / (float)stepsFull;
eg->nsteps = stepsFull; // stepsFull * (eg->egval / MAX_EG);
eg->nsteps = stepsFull * (eg->egval / MAX_EG);
break;
}
case release:
Expand Down
3 changes: 1 addition & 2 deletions src/createChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function createChannel(uiController, channelId, sf2, apath) {
return;
}
await spinner.shipProgram(program, pid | bid);
uiController.hidden = false;
uiController.name = program.name;
uiController.presetId = this.presetId;
uiController.zone = program.filterKV(60, 60)[0];
Expand All @@ -47,7 +46,7 @@ export function createChannel(uiController, channelId, sf2, apath) {
zone.arr,
]);
});

uiController.zone = zones[0];
if (!zones[0]) return;
return zones[0];
},
Expand Down
21 changes: 5 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { mkdiv, mkdiv2 } from "../mkdiv/mkdiv.js";
import { mkui } from "./ui.js";
import SF2Service from "../sf2-service/index.js";
import { fetchmidilist } from "./midilist.js";
import { mkeventsPipe } from "./mkeventsPipe.js";
import { createChannel } from "./createChannel.js";
import { DRUMSCHANNEL, ccnames, midi_ch_cmds } from "./constants.js";
Expand All @@ -20,7 +19,7 @@ import {
import { initNavigatorMidiAccess } from "./initNavigatorMidiAccess.js";

const urlParams = new URLSearchParams(document.location.search);
const sf2file = urlParams.get("sf2file") || "static/file.sf2";
const sf2file = urlParams.get("sf2file") || "static/SoundBlasterOld.sf2";
const midiUrl = urlParams.get("midiUrl") || "song.mid";

// import * as sequence from "../dist/sequence.js";
Expand Down Expand Up @@ -74,13 +73,6 @@ let uiControllers, ctx;

const channels = [];

const midiList = await fetchmidilist();
stdout(midiList[0].Url + " ");

const mUrl = midiUrl
? midiList.map((f) => f.Url).find((f) => f.includes(midiUrl))
: midiUrl;

for (const f of sf2list) sf2select.append(mkdiv("option", { value: f }, f));
sf2select.value = sf2file;
sf2select.onchange = (e) => {
Expand All @@ -93,19 +85,18 @@ const midiSelect = mkdiv2({
style: "width:300px",
value: midiUrl,
oninput: function (e) {
document.location.href = "?midiUrl=" + e.target.value;
document.location.href = "?midiUrl=" + encodeURIComponent(e.target.value);
},
children: [
mkdiv("option", { name: "select midi", value: null }, "select midi file"),
...mfilelist.map((f) =>
mkdiv("option", { value: f }, decodeURI(f).split("/").pop())
),
...midiList.map((f) => mkdiv("option", { value: f.Url, name: f.Name })),
],
});
midiSelect.value = mUrl;

midiSelect.attachTo(document.querySelector("#midilist"));
midiSelect.value = midiUrl;
ctx = new AudioContext({
sampleRate: 44100,
});
Expand Down Expand Up @@ -143,9 +134,8 @@ for (let i = 0; i < 16; i++) {

document.body.querySelector(".tabs > input").setAttribute("checked", "");

// onMidionURLSelect(mUrl);
if (mUrl) {
await onMidionURLSelect(mUrl);
if (midiUrl) {
await onMidionURLSelect(midiUrl);
} else {
channels[nextChannel++].setProgram(0, 0);
channels[DRUMSCHANNEL].setProgram(0, 128);
Expand Down Expand Up @@ -323,7 +313,6 @@ function draw() {
chartRect(cv1, apath.analysis.frequencyBins);
chart(cv2, apath.analysis.waveForm);
for (const c of uiControllers) {
if (!c.active) continue;
c.rendFrame(ctx.currentTime);
}

Expand Down

0 comments on commit bff9a1c

Please sign in to comment.