Skip to content

Commit

Permalink
consistency improvements
Browse files Browse the repository at this point in the history
and (almost) all console.logs changed to console.info
  • Loading branch information
spessasus committed Jun 7, 2024
1 parent 25a8c80 commit 5a0320d
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 48 deletions.
7 changes: 3 additions & 4 deletions src/spessasynth_lib/midi_parser/midi_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ export class MIDI{
{
const decoded = decoder.decode(messageData.slice(7, messageData.length - 3)) + "\n";
this.copyright += decoded;
console.log(`%cDecoded Roland SC message! %c${decoded}`,
console.info(`%cDecoded Roland SC message! %c${decoded}`,
consoleColors.recognized,
consoleColors.value)
}
}
}
this.tracks.push(track);
console.log(`%cParsed %c${this.tracks.length}%c / %c${this.tracksAmount}`,
console.info(`%cParsed %c${this.tracks.length}%c / %c${this.tracksAmount}`,
consoleColors.info,
consoleColors.value,
consoleColors.info,
Expand All @@ -260,7 +260,7 @@ export class MIDI{
}
this.firstNoteOn = Math.min(...firstNoteOns);

console.log(`%cMIDI file parsed. Total tick time: %c${this.lastVoiceEventTick}`,
console.info(`%cMIDI file parsed. Total tick time: %c${this.lastVoiceEventTick}`,
consoleColors.info,
consoleColors.recognized);
console.groupEnd();
Expand Down Expand Up @@ -300,7 +300,6 @@ export class MIDI{
message.messageStatusByte < messageTypes.systemExclusive
) === undefined)
{
console.log("message", this.tracks[0])
let name = this.tracks[0].find(message => message.messageStatusByte === messageTypes.trackName);
if(name)
{
Expand Down
8 changes: 3 additions & 5 deletions src/spessasynth_lib/sequencer/sequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class Sequencer {
*/
this.duration = this.ticksToSeconds(this.midiData.lastVoiceEventTick);

console.log(`%cTOTAL TIME: ${formatTime(Math.round(this.duration)).time}`, consoleColors.recognized);
console.info(`%cTotal song time: ${formatTime(Math.round(this.duration)).time}`, consoleColors.recognized);
this.midiPortChannelOffset = 0;
this.midiPortChannelOffsets = {};

Expand Down Expand Up @@ -319,8 +319,6 @@ export class Sequencer {
let elapsedTime = 0;
let oneTickToSeconds = 60 / (120 * this.midiData.timeDivision);
let eventIndex = 0;

console.log("%cLoading note times for note rendering...", consoleColors.warn);
while(eventIndex < events.length)
{
const event = events[eventIndex];
Expand Down Expand Up @@ -369,7 +367,7 @@ export class Sequencer {
elapsedTime += oneTickToSeconds * (events[eventIndex].ticks - event.ticks);
}

console.log("%cFinished loading note times and ready to render the sequence!", consoleColors.info);
console.info("%cFinished loading note times and ready to render the sequence!", consoleColors.info);
this.renderer.connectSequencer(noteTimes, this);
}

Expand Down Expand Up @@ -823,7 +821,7 @@ export class Sequencer {
break;

default:
console.log(`%cUnrecognized Event: %c${event.messageStatusByte}%c status byte: %c${Object.keys(messageTypes).find(k => messageTypes[k] === statusByteData.status)}`,
console.info(`%cUnrecognized Event: %c${event.messageStatusByte}%c status byte: %c${Object.keys(messageTypes).find(k => messageTypes[k] === statusByteData.status)}`,
consoleColors.warn,
consoleColors.unrecognized,
consoleColors.warn,
Expand Down
3 changes: 0 additions & 3 deletions src/spessasynth_lib/soundfont/chunk/modulators.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {signedInt16, readByte, readBytesAsUintLittleEndian} from "../../utils/byte_functions.js";
import { ShiftableByteArray } from '../../utils/shiftable_array.js';
import { generatorTypes } from './generators.js'
import { consoleColors } from '../../utils/other.js'
import { midiControllers } from '../../midi_parser/midi_message.js'

/**
Expand Down Expand Up @@ -219,8 +218,6 @@ export const defaultModulators = [
})
];

console.log("%cDefault Modulators:", consoleColors.recognized, defaultModulators)

/**
* Reads the modulator chunk
* @param modulatorChunk {RiffChunk}
Expand Down
4 changes: 3 additions & 1 deletion src/spessasynth_lib/soundfont/soundfont_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ export class SoundFont2
}
}
if(preset) {
console.info(`%cPreset at bank ${bankNr} not found. Replaced with ${preset.presetName}`, consoleColors.warn);
console.info(`%cPreset ${bankNr}.${presetNr} not found. Replaced with %c${preset.presetName} (${preset.bank}.${preset.program})`,
consoleColors.warn,
consoleColors.recognized);
}
}
if(!preset)
Expand Down
34 changes: 17 additions & 17 deletions src/spessasynth_lib/synthetizer/synthetizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Synthetizer {
* @param soundFont {SoundFont2}
*/
constructor(targetNode, soundFont) {
console.log("%cInitializing SpessaSynth synthesizer...", consoleColors.info);
console.info("%cInitializing SpessaSynth synthesizer...", consoleColors.info);
this.soundFont = soundFont;
this.context = targetNode.context;

Expand Down Expand Up @@ -89,7 +89,7 @@ export class Synthetizer {
this.percussionPreset = this.soundFont.getPreset(128, 0);

this.initializeSynthesisSystem();
console.log("%cSpessaSynth is ready!", consoleColors.recognized);
console.info("%cSpessaSynth is ready!", consoleColors.recognized);
}

initializeSynthesisSystem()
Expand Down Expand Up @@ -216,7 +216,7 @@ export class Synthetizer {
* @param force {boolean} if we should instantly kill the note, defaults to false
*/
stopAll(force=false) {
console.log("%cStop all received!", consoleColors.info);
console.info("%cStop all received!", consoleColors.info);
this.synthesisSystem.stopAllChannels(force);
this.eventHandler.callEvent("stopall", {});
}
Expand All @@ -240,7 +240,7 @@ export class Synthetizer {
if(this.system === "gm")
{
// gm ignores bank select
console.log("%cIgnoring the Bank Select, as the synth is in GM mode.", consoleColors.info);
console.info(`%cIgnoring the Bank Select (${controllerValue}), as the synth is in GM mode.`, consoleColors.info);
return;
}
let bankNr = controllerValue;
Expand Down Expand Up @@ -295,7 +295,7 @@ export class Synthetizer {
*/
resetControllers()
{
console.log("%cResetting all controllers!", consoleColors.info);
console.info("%cResetting all controllers!", consoleColors.info);
for(let channelNumber = 0; channelNumber < this.synthesisSystem.channelsAmount; channelNumber++)
{
// reset
Expand Down Expand Up @@ -478,7 +478,7 @@ export class Synthetizer {
switch (type)
{
default:
console.log(`%cUnrecognized SysEx: %c${arrayToHexString(messageData)}`,
console.info(`%cUnrecognized SysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.unrecognized);
break;
Expand All @@ -490,17 +490,17 @@ export class Synthetizer {
{
if(messageData[3] === 0x01)
{
console.log("%cGM system on", consoleColors.info);
console.info("%cGM system on", consoleColors.info);
this.system = "gm";
}
else if(messageData[3] === 0x03)
{
console.log("%cGM2 system on", consoleColors.info);
console.info("%cGM2 system on", consoleColors.info);
this.system = "gm2";
}
else
{
console.log("%cGM system off, defaulting to GS", consoleColors.info);
console.info("%cGM system off, defaulting to GS", consoleColors.info);
this.system = "gs";
}
}
Expand Down Expand Up @@ -535,7 +535,7 @@ export class Synthetizer {
if(messageData[7] === 0x00 && messageData[6] === 0x7F)
{
// this is a GS reset
console.log("%cGS system on", consoleColors.info);
console.info("%cGS system on", consoleColors.info);
this.system = "gs";
return;
}
Expand All @@ -547,7 +547,7 @@ export class Synthetizer {
const channel = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15][messageData[5] & 0x0F]; // for example 1A means A = 11, which corresponds to channel 12 (counting from 1)

this.setDrums(channel, messageData[7] > 0 && messageData[5] >> 4); // if set to other than 0, is a drum channel
console.log(
console.info(
`%cChannel %c${channel}%c ${this.synthesisSystem.midiChannels[channel].percussionChannel ?
"is now a drum channel"
:
Expand All @@ -564,7 +564,7 @@ export class Synthetizer {
if(messageData[4] === 0x40 && messageData[6] === 0x06 && messageData[5] === 0x00)
{
// roland master pan
console.log(`%cRoland Master Pan set to: %c${messageData[7]}%c with: %c${arrayToHexString(messageData)}`,
console.info(`%cRoland Master Pan set to: %c${messageData[7]}%c with: %c${arrayToHexString(messageData)}`,
consoleColors.info,
consoleColors.value,
consoleColors.info,
Expand All @@ -574,7 +574,7 @@ export class Synthetizer {
else
{
// this is some other GS sysex...
console.log(`%cUnrecognized Roland %cGS %cSysEx: %c${arrayToHexString(messageData)}`,
console.info(`%cUnrecognized Roland %cGS %cSysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.recognized,
consoleColors.warn,
Expand All @@ -586,7 +586,7 @@ export class Synthetizer {
{
// this is a roland master volume message
this.volumeController.gain.value = messageData[7] / 100 * DEFAULT_GAIN;
console.log(`%cRoland Master Volume control set to: %c${messageData[7]}%c via: %c${arrayToHexString(messageData)}`,
console.info(`%cRoland Master Volume control set to: %c${messageData[7]}%c via: %c${arrayToHexString(messageData)}`,
consoleColors.info,
consoleColors.value,
consoleColors.info,
Expand All @@ -595,7 +595,7 @@ export class Synthetizer {
else
{
// this is something else...
console.log(`%cUnrecognized Roland SysEx: %c${arrayToHexString(messageData)}`,
console.info(`%cUnrecognized Roland SysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.unrecognized);
}
Expand All @@ -606,12 +606,12 @@ export class Synthetizer {
// XG on
if(messageData[2] === 0x4C && messageData[5] === 0x7E && messageData[6] === 0x00)
{
console.log("%cXG system on", consoleColors.info);
console.info("%cXG system on", consoleColors.info);
this.system = "xg";
}
else
{
console.log(`%cUnrecognized Yamaha SysEx: %c${arrayToHexString(messageData)}`,
console.info(`%cUnrecognized Yamaha SysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.unrecognized);
}
Expand Down
17 changes: 12 additions & 5 deletions src/spessasynth_lib/synthetizer/worklet_system/worklet_system.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ export class WorkletSystem {
setPitchBendRange(channel, semitones)
{
this.midiChannels[channel].channelPitchBendRange = semitones;
console.log(`%cChannel ${channel + 1} bend range. Semitones: %c${semitones}`,
console.info(`%cChannel ${channel} bend range. Semitones: %c${semitones}`,
consoleColors.info,
consoleColors.value);
this.post({
Expand Down Expand Up @@ -628,6 +628,13 @@ export class WorkletSystem {
switch(this.midiChannels[channel].NRPFine)
{
default:
console.info(`%cUnrecognized NRPN for %c${channel}%c: %c${this.midiChannels[channel].NRPCoarse} ${this.midiChannels[channel].NRPFine}%c data value: %c${dataValue}`,
consoleColors.warn,
consoleColors.recognized,
consoleColors.warn,
consoleColors.unrecognized,
consoleColors.warn,
consoleColors.value);
break;

// vibrato rate
Expand All @@ -642,7 +649,7 @@ export class WorkletSystem {
}
addDefaultVibrato();
this.midiChannels[channel].vibrato.rate = (dataValue / 64) * 8;
console.log(`%cVibrato rate for channel %c${channel + 1}%c is now set to %c${this.midiChannels[channel].vibrato.rate}%cHz.`,
console.info(`%cVibrato rate for channel %c${channel}%c is now set to %c${this.midiChannels[channel].vibrato.rate}%cHz.`,
consoleColors.info,
consoleColors.recognized,
consoleColors.info,
Expand All @@ -668,7 +675,7 @@ export class WorkletSystem {
}
addDefaultVibrato();
this.midiChannels[channel].vibrato.depth = dataValue / 2;
console.log(`%cVibrato depth for %c${channel + 1}%c is now set to %c${this.midiChannels[channel].vibrato.depth} %ccents range of detune.`,
console.info(`%cVibrato depth for %c${channel}%c is now set to %c${this.midiChannels[channel].vibrato.depth}%c cents range of detune.`,
consoleColors.info,
consoleColors.recognized,
consoleColors.info,
Expand All @@ -694,7 +701,7 @@ export class WorkletSystem {
}
addDefaultVibrato();
this.midiChannels[channel].vibrato.delay = (dataValue / 64) / 3;
console.log(`%cVibrato delay for %c${channel}%c is now set to %c${this.midiChannels[channel].vibrato.delay} %cseconds.`,
console.info(`%cVibrato delay for %c${channel}%c is now set to %c${this.midiChannels[channel].vibrato.delay}%c seconds.`,
consoleColors.info,
consoleColors.recognized,
consoleColors.info,
Expand Down Expand Up @@ -747,7 +754,7 @@ export class WorkletSystem {
setChannelTuning(channel, semitones)
{
this.midiChannels[channel].channelTuningSemitones = semitones;
console.log(`%cChannel ${channel + 1} tuning. Semitones: %c${semitones}`,
console.info(`%cChannel ${channel} tuning. Semitones: %c${semitones}`,
consoleColors.info,
consoleColors.value);
this.post({
Expand Down
2 changes: 1 addition & 1 deletion src/spessasynth_lib/utils/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function calculateRGB(rgbString, operation)

/**
* Does what it says
* @param arr {ShiftableByteArray}
* @param arr {ArrayLike<number>}
* @returns {string}
*/
export function arrayToHexString(arr) {
Expand Down
24 changes: 12 additions & 12 deletions src/website/ui/synthesizer_ui/synthetizer_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,19 @@ export class SynthetizerUI
LOCALE_PATH + "channelController.panMeter",
this.locale,
[channelNumber + 1],
-1,
1,
0,
127,
true,
val => {
changeCCUserFunction(midiControllers.pan, (val / 2 + 0.5) * 127, pan);
changeCCUserFunction(midiControllers.pan, Math.round(val), pan);
},
() => {
this.synth.lockController(channelNumber, midiControllers.pan, true);
},
() => {
this.synth.lockController(channelNumber, midiControllers.pan, false);
});
pan.update(0);
pan.update(64);
controller.appendChild(pan.div);

// expression controller
Expand All @@ -433,7 +433,7 @@ export class SynthetizerUI
127,
true,
val => {
changeCCUserFunction(midiControllers.expressionController, val, expression);
changeCCUserFunction(midiControllers.expressionController, Math.round(val), expression);
},
() => {
this.synth.lockController(channelNumber, midiControllers.expressionController, true);
Expand All @@ -453,7 +453,7 @@ export class SynthetizerUI
127,
true,
val => {
changeCCUserFunction(midiControllers.mainVolume, val, volume);
changeCCUserFunction(midiControllers.mainVolume, Math.round(val), volume);
},
() => {
this.synth.lockController(channelNumber, midiControllers.mainVolume, true);
Expand All @@ -473,7 +473,7 @@ export class SynthetizerUI
127,
true,
val => {
changeCCUserFunction(midiControllers.modulationWheel, val, modulation);
changeCCUserFunction(midiControllers.modulationWheel, Math.round(val), modulation);
},
() => {
this.synth.lockController(channelNumber, midiControllers.modulationWheel, true);
Expand All @@ -493,7 +493,7 @@ export class SynthetizerUI
127,
true,
val => {
changeCCUserFunction(midiControllers.effects3Depth, val, chorus);
changeCCUserFunction(midiControllers.effects3Depth, Math.round(val), chorus);
},
() => {
this.synth.lockController(channelNumber, midiControllers.effects3Depth, true);
Expand All @@ -513,7 +513,7 @@ export class SynthetizerUI
127,
true,
val => {
changeCCUserFunction(midiControllers.effects1Depth, val, reverb);
changeCCUserFunction(midiControllers.effects1Depth, Math.round(val), reverb);
},
() => {
this.synth.lockController(channelNumber, midiControllers.effects1Depth, true);
Expand Down Expand Up @@ -685,17 +685,17 @@ export class SynthetizerUI

case midiControllers.expressionController:
// expression
this.controllers[channel].expression.update(Math.round(value));
this.controllers[channel].expression.update(value);
break;

case midiControllers.mainVolume:
// volume
this.controllers[channel].volume.update(Math.round(value));
this.controllers[channel].volume.update(value);
break;

case midiControllers.pan:
// pan
this.controllers[channel].pan.update((value - 63) / 64);
this.controllers[channel].pan.update(value);
break;

case midiControllers.modulationWheel:
Expand Down

0 comments on commit 5a0320d

Please sign in to comment.