Skip to content

Commit

Permalink
Two instruments for playback
Browse files Browse the repository at this point in the history
  • Loading branch information
belinde committed May 2, 2024
1 parent a0f4865 commit 8494e33
Show file tree
Hide file tree
Showing 192 changed files with 217 additions and 81 deletions.
Binary file removed assets/notes/1A.mp3
Binary file not shown.
Binary file removed assets/notes/1AB.mp3
Binary file not shown.
Binary file removed assets/notes/1B.mp3
Binary file not shown.
Binary file removed assets/notes/1E.mp3
Binary file not shown.
Binary file removed assets/notes/1F.mp3
Binary file not shown.
Binary file removed assets/notes/1FG.mp3
Binary file not shown.
Binary file removed assets/notes/1G.mp3
Binary file not shown.
Binary file removed assets/notes/1GA.mp3
Binary file not shown.
Binary file removed assets/notes/2A.mp3
Binary file not shown.
Binary file removed assets/notes/2AB.mp3
Binary file not shown.
Binary file removed assets/notes/2B.mp3
Binary file not shown.
Binary file removed assets/notes/2C.mp3
Binary file not shown.
Binary file removed assets/notes/2CD.mp3
Binary file not shown.
Binary file removed assets/notes/2D.mp3
Binary file not shown.
Binary file removed assets/notes/2DE.mp3
Binary file not shown.
Binary file removed assets/notes/2E.mp3
Binary file not shown.
Binary file removed assets/notes/2F.mp3
Binary file not shown.
Binary file removed assets/notes/2FG.mp3
Binary file not shown.
Binary file removed assets/notes/2G.mp3
Binary file not shown.
Binary file removed assets/notes/2GA.mp3
Binary file not shown.
Binary file removed assets/notes/3A.mp3
Binary file not shown.
Binary file removed assets/notes/3AB.mp3
Binary file not shown.
Binary file removed assets/notes/3B.mp3
Binary file not shown.
Binary file removed assets/notes/3C.mp3
Binary file not shown.
Binary file removed assets/notes/3CD.mp3
Binary file not shown.
Binary file removed assets/notes/3D.mp3
Binary file not shown.
Binary file removed assets/notes/3DE.mp3
Binary file not shown.
Binary file removed assets/notes/3E.mp3
Binary file not shown.
Binary file removed assets/notes/3F.mp3
Binary file not shown.
Binary file removed assets/notes/3FG.mp3
Binary file not shown.
Binary file removed assets/notes/3G.mp3
Binary file not shown.
Binary file removed assets/notes/3GA.mp3
Binary file not shown.
Binary file removed assets/notes/4A.mp3
Binary file not shown.
Binary file removed assets/notes/4AB.mp3
Binary file not shown.
Binary file removed assets/notes/4B.mp3
Binary file not shown.
Binary file removed assets/notes/4C.mp3
Binary file not shown.
Binary file removed assets/notes/4CD.mp3
Binary file not shown.
Binary file removed assets/notes/4D.mp3
Binary file not shown.
Binary file removed assets/notes/4DE.mp3
Binary file not shown.
Binary file removed assets/notes/4E.mp3
Binary file not shown.
Binary file removed assets/notes/4F.mp3
Binary file not shown.
Binary file removed assets/notes/4FG.mp3
Binary file not shown.
Binary file removed assets/notes/4G.mp3
Binary file not shown.
Binary file removed assets/notes/4GA.mp3
Binary file not shown.
Binary file removed assets/notes/5A.mp3
Binary file not shown.
Binary file removed assets/notes/5AB.mp3
Binary file not shown.
Binary file removed assets/notes/5B.mp3
Binary file not shown.
Binary file removed assets/notes/5C.mp3
Binary file not shown.
Binary file removed assets/notes/5CD.mp3
Binary file not shown.
Binary file removed assets/notes/5D.mp3
Binary file not shown.
Binary file removed assets/notes/5DE.mp3
Binary file not shown.
Binary file removed assets/notes/5E.mp3
Binary file not shown.
Binary file removed assets/notes/5F.mp3
Binary file not shown.
Binary file removed assets/notes/5FG.mp3
Binary file not shown.
Binary file removed assets/notes/5G.mp3
Binary file not shown.
Binary file removed assets/notes/5GA.mp3
Binary file not shown.
Binary file removed assets/notes/6C.mp3
Binary file not shown.
Binary file removed assets/notes/6CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/0B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1A.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1AB.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1D.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1DE.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1E.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1F.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1FG.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1G.mp3
Binary file not shown.
Binary file added assets/notes/pluck/1GA.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2A.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2AB.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2D.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2DE.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2E.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2F.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2FG.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2G.mp3
Binary file not shown.
Binary file added assets/notes/pluck/2GA.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3A.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3AB.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3D.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3DE.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3E.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3F.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3FG.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3G.mp3
Binary file not shown.
Binary file added assets/notes/pluck/3GA.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4A.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4AB.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4D.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4DE.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4E.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4F.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4FG.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4G.mp3
Binary file not shown.
Binary file added assets/notes/pluck/4GA.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5A.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5AB.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5B.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5CD.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5D.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5DE.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5E.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5F.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5FG.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5G.mp3
Binary file not shown.
Binary file added assets/notes/pluck/5GA.mp3
Binary file not shown.
Binary file added assets/notes/pluck/6C.mp3
Binary file not shown.
Binary file added assets/notes/pluck/6CD.mp3
Binary file not shown.
Binary file renamed assets/notes/6D.mp3 → assets/notes/pluck/6D.mp3
Binary file not shown.
Binary file added assets/notes/synth/0B.mp3
Binary file not shown.
Binary file added assets/notes/synth/1A.mp3
Binary file not shown.
Binary file added assets/notes/synth/1AB.mp3
Binary file not shown.
Binary file added assets/notes/synth/1B.mp3
Binary file not shown.
Binary file added assets/notes/synth/1C.mp3
Binary file not shown.
Binary file added assets/notes/synth/1CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/1D.mp3
Binary file not shown.
Binary file added assets/notes/synth/1DE.mp3
Binary file not shown.
Binary file added assets/notes/synth/1E.mp3
Binary file not shown.
Binary file added assets/notes/synth/1F.mp3
Binary file not shown.
Binary file added assets/notes/synth/1FG.mp3
Binary file not shown.
Binary file added assets/notes/synth/1G.mp3
Binary file not shown.
Binary file added assets/notes/synth/1GA.mp3
Binary file not shown.
Binary file added assets/notes/synth/2A.mp3
Binary file not shown.
Binary file added assets/notes/synth/2AB.mp3
Binary file not shown.
Binary file added assets/notes/synth/2B.mp3
Binary file not shown.
Binary file added assets/notes/synth/2C.mp3
Binary file not shown.
Binary file added assets/notes/synth/2CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/2D.mp3
Binary file not shown.
Binary file added assets/notes/synth/2DE.mp3
Binary file not shown.
Binary file added assets/notes/synth/2E.mp3
Binary file not shown.
Binary file added assets/notes/synth/2F.mp3
Binary file not shown.
Binary file added assets/notes/synth/2FG.mp3
Binary file not shown.
Binary file added assets/notes/synth/2G.mp3
Binary file not shown.
Binary file added assets/notes/synth/2GA.mp3
Binary file not shown.
Binary file added assets/notes/synth/3A.mp3
Binary file not shown.
Binary file added assets/notes/synth/3AB.mp3
Binary file not shown.
Binary file added assets/notes/synth/3B.mp3
Binary file not shown.
Binary file added assets/notes/synth/3C.mp3
Binary file not shown.
Binary file added assets/notes/synth/3CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/3D.mp3
Binary file not shown.
Binary file added assets/notes/synth/3DE.mp3
Binary file not shown.
Binary file added assets/notes/synth/3E.mp3
Binary file not shown.
Binary file added assets/notes/synth/3F.mp3
Binary file not shown.
Binary file added assets/notes/synth/3FG.mp3
Binary file not shown.
Binary file added assets/notes/synth/3G.mp3
Binary file not shown.
Binary file added assets/notes/synth/3GA.mp3
Binary file not shown.
Binary file added assets/notes/synth/4A.mp3
Binary file not shown.
Binary file added assets/notes/synth/4AB.mp3
Binary file not shown.
Binary file added assets/notes/synth/4B.mp3
Binary file not shown.
Binary file added assets/notes/synth/4C.mp3
Binary file not shown.
Binary file added assets/notes/synth/4CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/4D.mp3
Binary file not shown.
Binary file added assets/notes/synth/4DE.mp3
Binary file not shown.
Binary file added assets/notes/synth/4E.mp3
Binary file not shown.
Binary file added assets/notes/synth/4F.mp3
Binary file not shown.
Binary file added assets/notes/synth/4FG.mp3
Binary file not shown.
Binary file added assets/notes/synth/4G.mp3
Binary file not shown.
Binary file added assets/notes/synth/4GA.mp3
Binary file not shown.
Binary file added assets/notes/synth/5A.mp3
Binary file not shown.
Binary file added assets/notes/synth/5AB.mp3
Binary file not shown.
Binary file added assets/notes/synth/5B.mp3
Binary file not shown.
Binary file added assets/notes/synth/5C.mp3
Binary file not shown.
Binary file added assets/notes/synth/5CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/5D.mp3
Binary file not shown.
Binary file added assets/notes/synth/5DE.mp3
Binary file not shown.
Binary file added assets/notes/synth/5E.mp3
Binary file not shown.
Binary file added assets/notes/synth/5F.mp3
Binary file not shown.
Binary file added assets/notes/synth/5FG.mp3
Binary file not shown.
Binary file added assets/notes/synth/5G.mp3
Binary file not shown.
Binary file added assets/notes/synth/5GA.mp3
Binary file not shown.
Binary file added assets/notes/synth/6C.mp3
Binary file not shown.
Binary file added assets/notes/synth/6CD.mp3
Binary file not shown.
Binary file added assets/notes/synth/6D.mp3
Binary file not shown.
28 changes: 17 additions & 11 deletions createNoteAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,30 @@ const NOTEREF = [

const { exec } = require("child_process");

const START = 8;
const launcher = (n, vol, folder, synth) => {
const file = `./assets/notes/${folder}/${NOTEREF[n]}.mp3`;
exec(
`sox -n ${file} synth ${synth} channels 1 vol ${vol} dB`,
(err, stdout, stderr) => {
stdout && console.log(NOTEREF[n], stdout);
stderr && console.error(NOTEREF[n], stderr);
err && console.error(NOTEREF[n], err);
}
);
};
const START = 3;
const END = 66;
const FROMVOL = 0;
const TOVOL = -20;

for (let n = START; n <= END; n++) {
const FREQ = 440 * Math.pow(2, (n - 49) / 12);
const VOL =
const Hz = 440 * Math.pow(2, (n - 49) / 12);
const vol =
Math.round(
100 * (FROMVOL + ((TOVOL - FROMVOL) * (n - START)) / (END - START)),
2
) / 100;
// console.log(`"${NOTEREF[n]}": ${FREQ} --> ${VOL}`);
exec(
`sox -n ./assets/notes/${NOTEREF[n]}.mp3 synth 2 pluck ${FREQ} channels 1 vol ${VOL} dB`,
(err, _, stderr) => {
stderr && console.error(NOTEREF[n], stderr);
err && console.error(NOTEREF[n], err);
}
);

launcher(n, vol, "pluck", `2 pluck ${Hz}`);
launcher(n, vol, "synth", `2 sin ${Hz} trapezium ${Hz}`);
}
12 changes: 11 additions & 1 deletion src/Settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FILENAME_SETTINGS } from "./constants";
import { readJsonFile, writeJsonFile } from "./functions";
import { InitialNote, NoteNameStyle } from "./types";
import { InitialNote, Instrument, NoteNameStyle } from "./types";

export type StandardSection = Pick<InitialNote, "section" | "subsection">;

Expand Down Expand Up @@ -30,6 +30,7 @@ export class Settings {
private concertMode?: string;
private subscribers: Set<() => void> = new Set();
private standardSections: StandardSection[] = [];
private instrument: Instrument = "synth";

public subscribe(callback: () => void) {
this.subscribers.add(callback);
Expand Down Expand Up @@ -87,4 +88,13 @@ export class Settings {
this.standardSections = value;
await this.persist();
}

getInstrument() {
return this.instrument;
}

async setInstrument(value: Instrument) {
this.instrument = value;
await this.persist();
}
}
33 changes: 27 additions & 6 deletions src/components/PlayNote.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Audio } from "expo-av";
import { FC, useEffect, useRef } from "react";
import { FC, useEffect, useRef, useState } from "react";
import { IconButton } from "react-native-paper";
import { NOTEFILES } from "../constants";
import { Alteration, Note, NoteName, NoteResourceName } from "../types";
import { useDataContext } from "../hooks/useDataContext";
import {
Alteration,
Instrument,
Note,
NoteName,
NoteResourceName,
} from "../types";

const ResMap: Record<`${NoteName}${Alteration}`, [string, number]> = {
Cb: ["B", -1],
Expand All @@ -21,23 +28,37 @@ const ResMap: Record<`${NoteName}${Alteration}`, [string, number]> = {
"B#": ["C", 1],
};

const getResourceName = (note: Note): NoteResourceName | null => {
const getResourceName = (
note: Note,
instrument: Instrument
): NoteResourceName | null => {
let resourceName: NoteResourceName =
`${note.octave}${note.note}` as NoteResourceName;
`${instrument}${note.octave}${note.note}` as NoteResourceName;

if (note.alteration) {
const [baseName, changeOctave] = ResMap[`${note.note}${note.alteration}`];
const octave = note.octave + changeOctave;
resourceName = `${octave}${baseName}` as NoteResourceName;
resourceName = `${instrument}${octave}${baseName}` as NoteResourceName;
}

return resourceName in NOTEFILES ? resourceName : null;
};

export const PlayNote: FC<{ note: Note }> = (props) => {
const data = useDataContext();
const [instrument, setInstrument] = useState(() =>
data.settings.getInstrument()
);
useEffect(
() =>
data.settings.subscribe(() => {
setInstrument(data.settings.getInstrument());
}),
[data.settings]
);
const sound = useRef<Audio.Sound>();

const soundKey = getResourceName(props.note);
const soundKey = getResourceName(props.note, instrument);

useEffect(() => {
if (soundKey) {
Expand Down
184 changes: 124 additions & 60 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,66 +29,130 @@ export const NOTE_NAMES: Record<(typeof NOTES)[number], string> = {
};

export const NOTEFILES = {
"1C": require("../assets/notes/1C.mp3"),
"1CD": require("../assets/notes/1CD.mp3"),
"1D": require("../assets/notes/1D.mp3"),
"1DE": require("../assets/notes/1DE.mp3"),
"1E": require("../assets/notes/1E.mp3"),
"1F": require("../assets/notes/1F.mp3"),
"1FG": require("../assets/notes/1FG.mp3"),
"1G": require("../assets/notes/1G.mp3"),
"1GA": require("../assets/notes/1GA.mp3"),
"1A": require("../assets/notes/1A.mp3"),
"1AB": require("../assets/notes/1AB.mp3"),
"1B": require("../assets/notes/1B.mp3"),
"2C": require("../assets/notes/2C.mp3"),
"2CD": require("../assets/notes/2CD.mp3"),
"2D": require("../assets/notes/2D.mp3"),
"2DE": require("../assets/notes/2DE.mp3"),
"2E": require("../assets/notes/2E.mp3"),
"2F": require("../assets/notes/2F.mp3"),
"2FG": require("../assets/notes/2FG.mp3"),
"2G": require("../assets/notes/2G.mp3"),
"2GA": require("../assets/notes/2GA.mp3"),
"2A": require("../assets/notes/2A.mp3"),
"2AB": require("../assets/notes/2AB.mp3"),
"2B": require("../assets/notes/2B.mp3"),
"3C": require("../assets/notes/3C.mp3"),
"3CD": require("../assets/notes/3CD.mp3"),
"3D": require("../assets/notes/3D.mp3"),
"3DE": require("../assets/notes/3DE.mp3"),
"3E": require("../assets/notes/3E.mp3"),
"3F": require("../assets/notes/3F.mp3"),
"3FG": require("../assets/notes/3FG.mp3"),
"3G": require("../assets/notes/3G.mp3"),
"3GA": require("../assets/notes/3GA.mp3"),
"3A": require("../assets/notes/3A.mp3"),
"3AB": require("../assets/notes/3AB.mp3"),
"3B": require("../assets/notes/3B.mp3"),
"4C": require("../assets/notes/4C.mp3"),
"4CD": require("../assets/notes/4CD.mp3"),
"4D": require("../assets/notes/4D.mp3"),
"4DE": require("../assets/notes/4DE.mp3"),
"4E": require("../assets/notes/4E.mp3"),
"4F": require("../assets/notes/4F.mp3"),
"4FG": require("../assets/notes/4FG.mp3"),
"4G": require("../assets/notes/4G.mp3"),
"4GA": require("../assets/notes/4GA.mp3"),
"4A": require("../assets/notes/4A.mp3"),
"4AB": require("../assets/notes/4AB.mp3"),
"4B": require("../assets/notes/4B.mp3"),
"5C": require("../assets/notes/5C.mp3"),
"5CD": require("../assets/notes/5CD.mp3"),
"5D": require("../assets/notes/5D.mp3"),
"5DE": require("../assets/notes/5DE.mp3"),
"5E": require("../assets/notes/5E.mp3"),
"5F": require("../assets/notes/5F.mp3"),
"5FG": require("../assets/notes/5FG.mp3"),
"5G": require("../assets/notes/5G.mp3"),
"5GA": require("../assets/notes/5GA.mp3"),
"5A": require("../assets/notes/5A.mp3"),
"5AB": require("../assets/notes/5AB.mp3"),
"5B": require("../assets/notes/5B.mp3"),
synth0B: require("../assets/notes/synth/0B.mp3"),
synth1C: require("../assets/notes/synth/1C.mp3"),
synth1CD: require("../assets/notes/synth/1CD.mp3"),
synth1D: require("../assets/notes/synth/1D.mp3"),
synth1DE: require("../assets/notes/synth/1DE.mp3"),
synth1E: require("../assets/notes/synth/1E.mp3"),
synth1F: require("../assets/notes/synth/1F.mp3"),
synth1FG: require("../assets/notes/synth/1FG.mp3"),
synth1G: require("../assets/notes/synth/1G.mp3"),
synth1GA: require("../assets/notes/synth/1GA.mp3"),
synth1A: require("../assets/notes/synth/1A.mp3"),
synth1AB: require("../assets/notes/synth/1AB.mp3"),
synth1B: require("../assets/notes/synth/1B.mp3"),
synth2C: require("../assets/notes/synth/2C.mp3"),
synth2CD: require("../assets/notes/synth/2CD.mp3"),
synth2D: require("../assets/notes/synth/2D.mp3"),
synth2DE: require("../assets/notes/synth/2DE.mp3"),
synth2E: require("../assets/notes/synth/2E.mp3"),
synth2F: require("../assets/notes/synth/2F.mp3"),
synth2FG: require("../assets/notes/synth/2FG.mp3"),
synth2G: require("../assets/notes/synth/2G.mp3"),
synth2GA: require("../assets/notes/synth/2GA.mp3"),
synth2A: require("../assets/notes/synth/2A.mp3"),
synth2AB: require("../assets/notes/synth/2AB.mp3"),
synth2B: require("../assets/notes/synth/2B.mp3"),
synth3C: require("../assets/notes/synth/3C.mp3"),
synth3CD: require("../assets/notes/synth/3CD.mp3"),
synth3D: require("../assets/notes/synth/3D.mp3"),
synth3DE: require("../assets/notes/synth/3DE.mp3"),
synth3E: require("../assets/notes/synth/3E.mp3"),
synth3F: require("../assets/notes/synth/3F.mp3"),
synth3FG: require("../assets/notes/synth/3FG.mp3"),
synth3G: require("../assets/notes/synth/3G.mp3"),
synth3GA: require("../assets/notes/synth/3GA.mp3"),
synth3A: require("../assets/notes/synth/3A.mp3"),
synth3AB: require("../assets/notes/synth/3AB.mp3"),
synth3B: require("../assets/notes/synth/3B.mp3"),
synth4C: require("../assets/notes/synth/4C.mp3"),
synth4CD: require("../assets/notes/synth/4CD.mp3"),
synth4D: require("../assets/notes/synth/4D.mp3"),
synth4DE: require("../assets/notes/synth/4DE.mp3"),
synth4E: require("../assets/notes/synth/4E.mp3"),
synth4F: require("../assets/notes/synth/4F.mp3"),
synth4FG: require("../assets/notes/synth/4FG.mp3"),
synth4G: require("../assets/notes/synth/4G.mp3"),
synth4GA: require("../assets/notes/synth/4GA.mp3"),
synth4A: require("../assets/notes/synth/4A.mp3"),
synth4AB: require("../assets/notes/synth/4AB.mp3"),
synth4B: require("../assets/notes/synth/4B.mp3"),
synth5C: require("../assets/notes/synth/5C.mp3"),
synth5CD: require("../assets/notes/synth/5CD.mp3"),
synth5D: require("../assets/notes/synth/5D.mp3"),
synth5DE: require("../assets/notes/synth/5DE.mp3"),
synth5E: require("../assets/notes/synth/5E.mp3"),
synth5F: require("../assets/notes/synth/5F.mp3"),
synth5FG: require("../assets/notes/synth/5FG.mp3"),
synth5G: require("../assets/notes/synth/5G.mp3"),
synth5GA: require("../assets/notes/synth/5GA.mp3"),
synth5A: require("../assets/notes/synth/5A.mp3"),
synth5AB: require("../assets/notes/synth/5AB.mp3"),
synth5B: require("../assets/notes/synth/5B.mp3"),
synth6C: require("../assets/notes/synth/6C.mp3"),
pluck0B: require("../assets/notes/pluck/0B.mp3"),
pluck1C: require("../assets/notes/pluck/1C.mp3"),
pluck1CD: require("../assets/notes/pluck/1CD.mp3"),
pluck1D: require("../assets/notes/pluck/1D.mp3"),
pluck1DE: require("../assets/notes/pluck/1DE.mp3"),
pluck1E: require("../assets/notes/pluck/1E.mp3"),
pluck1F: require("../assets/notes/pluck/1F.mp3"),
pluck1FG: require("../assets/notes/pluck/1FG.mp3"),
pluck1G: require("../assets/notes/pluck/1G.mp3"),
pluck1GA: require("../assets/notes/pluck/1GA.mp3"),
pluck1A: require("../assets/notes/pluck/1A.mp3"),
pluck1AB: require("../assets/notes/pluck/1AB.mp3"),
pluck1B: require("../assets/notes/pluck/1B.mp3"),
pluck2C: require("../assets/notes/pluck/2C.mp3"),
pluck2CD: require("../assets/notes/pluck/2CD.mp3"),
pluck2D: require("../assets/notes/pluck/2D.mp3"),
pluck2DE: require("../assets/notes/pluck/2DE.mp3"),
pluck2E: require("../assets/notes/pluck/2E.mp3"),
pluck2F: require("../assets/notes/pluck/2F.mp3"),
pluck2FG: require("../assets/notes/pluck/2FG.mp3"),
pluck2G: require("../assets/notes/pluck/2G.mp3"),
pluck2GA: require("../assets/notes/pluck/2GA.mp3"),
pluck2A: require("../assets/notes/pluck/2A.mp3"),
pluck2AB: require("../assets/notes/pluck/2AB.mp3"),
pluck2B: require("../assets/notes/pluck/2B.mp3"),
pluck3C: require("../assets/notes/pluck/3C.mp3"),
pluck3CD: require("../assets/notes/pluck/3CD.mp3"),
pluck3D: require("../assets/notes/pluck/3D.mp3"),
pluck3DE: require("../assets/notes/pluck/3DE.mp3"),
pluck3E: require("../assets/notes/pluck/3E.mp3"),
pluck3F: require("../assets/notes/pluck/3F.mp3"),
pluck3FG: require("../assets/notes/pluck/3FG.mp3"),
pluck3G: require("../assets/notes/pluck/3G.mp3"),
pluck3GA: require("../assets/notes/pluck/3GA.mp3"),
pluck3A: require("../assets/notes/pluck/3A.mp3"),
pluck3AB: require("../assets/notes/pluck/3AB.mp3"),
pluck3B: require("../assets/notes/pluck/3B.mp3"),
pluck4C: require("../assets/notes/pluck/4C.mp3"),
pluck4CD: require("../assets/notes/pluck/4CD.mp3"),
pluck4D: require("../assets/notes/pluck/4D.mp3"),
pluck4DE: require("../assets/notes/pluck/4DE.mp3"),
pluck4E: require("../assets/notes/pluck/4E.mp3"),
pluck4F: require("../assets/notes/pluck/4F.mp3"),
pluck4FG: require("../assets/notes/pluck/4FG.mp3"),
pluck4G: require("../assets/notes/pluck/4G.mp3"),
pluck4GA: require("../assets/notes/pluck/4GA.mp3"),
pluck4A: require("../assets/notes/pluck/4A.mp3"),
pluck4AB: require("../assets/notes/pluck/4AB.mp3"),
pluck4B: require("../assets/notes/pluck/4B.mp3"),
pluck5C: require("../assets/notes/pluck/5C.mp3"),
pluck5CD: require("../assets/notes/pluck/5CD.mp3"),
pluck5D: require("../assets/notes/pluck/5D.mp3"),
pluck5DE: require("../assets/notes/pluck/5DE.mp3"),
pluck5E: require("../assets/notes/pluck/5E.mp3"),
pluck5F: require("../assets/notes/pluck/5F.mp3"),
pluck5FG: require("../assets/notes/pluck/5FG.mp3"),
pluck5G: require("../assets/notes/pluck/5G.mp3"),
pluck5GA: require("../assets/notes/pluck/5GA.mp3"),
pluck5A: require("../assets/notes/pluck/5A.mp3"),
pluck5AB: require("../assets/notes/pluck/5AB.mp3"),
pluck5B: require("../assets/notes/pluck/5B.mp3"),
pluck6C: require("../assets/notes/pluck/6C.mp3"),
} as const;
export const PENTAGRAM_PREFERENCE: Record<Section, PentagramPreference> = {
soprani: "high",
Expand Down
39 changes: 36 additions & 3 deletions src/pages/Settings/SettingsSectionMusic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ import { FC, useCallback, useEffect, useState } from "react";
import { Divider, RadioButton, Text } from "react-native-paper";
import { StandardSection } from "../../Settings";
import { useDataContext } from "../../hooks/useDataContext";
import { NoteNameStyle } from "../../types";
import { Instrument, NoteNameStyle } from "../../types";
import { SectionSelector } from "./SectionSelector";
import { SettingsSection } from "./SettingsSection";

export const SettingsSectionMusic: FC = () => {
const data = useDataContext();
const [style, setStyle] = useState(data.settings.getNoteStyle());
const [instrument, setInstrument] = useState(data.settings.getInstrument());

useEffect(
() => data.settings.subscribe(() => setStyle(data.settings.getNoteStyle())),
() =>
data.settings.subscribe(() => {
setStyle(data.settings.getNoteStyle());
setInstrument(data.settings.getInstrument());
}),
[data.settings]
);

const [sections, setSections] = useState(data.settings.getStandardSections());
useEffect(
() =>
Expand All @@ -30,8 +37,32 @@ export const SettingsSectionMusic: FC = () => {

return (
<SettingsSection title="Musica" icon="music-clef-treble">
<Text variant="titleMedium">Nomi delle note:</Text>
<Text variant="titleMedium">Strumento di riproduzione:</Text>
<RadioButton.Group
onValueChange={(val) => {
data.settings.setInstrument(val as Instrument);
}}
value={instrument}
>
<RadioButton.Item
value="synth"
label="Sintetizzatore"
accessibilityLabel="Sintetizzatore"
aria-label="Sintetizzatore"
/>
<RadioButton.Item
value="pluck"
label="Chitarra"
accessibilityLabel="Chitarra"
aria-label="Chitarra"
/>
</RadioButton.Group>

<Divider />

<Text variant="titleMedium" style={{ marginTop: 16 }}>
Nomi delle note:
</Text>
<RadioButton.Group
onValueChange={(val) => {
data.settings.setNoteStyle(val as NoteNameStyle);
Expand All @@ -51,7 +82,9 @@ export const SettingsSectionMusic: FC = () => {
aria-label="C, D, E..."
/>
</RadioButton.Group>

<Divider />

<Text variant="titleMedium" style={{ marginTop: 16 }}>
Reparti normalmente utilizzati:
</Text>
Expand Down
Loading

0 comments on commit 8494e33

Please sign in to comment.