1 Commits

Author SHA1 Message Date
GitBluub e4a8eba699 feat: gen cover in populate wip 2023-11-15 13:08:16 +01:00
4 changed files with 13 additions and 43 deletions
+7 -1
View File
@@ -40,10 +40,16 @@ def getOrCreateArtist(name):
print(out)
return out["id"]
def gen_cover():
def populateFile(path, midi, mxl):
config = ConfigParser()
config.read(path)
mid = MidiFile(midi)
common = os.path.commonpath([midi, mxl])
png_path = f"{common}/illustration.png"
if not os.path.exists(png_path):
gen_cover(common)
metadata = config["Metadata"];
difficulties = dict(config["Difficulties"])
difficulties["length"] = round((mid.length), 2)
@@ -57,7 +63,7 @@ def populateFile(path, midi, mxl):
"artist": artistId,
"album": getOrCreateAlbum(metadata["Album"], artistId),
"genre": getOrCreateGenre(metadata["Genre"]),
"illustrationPath": f"/assets/{os.path.commonpath([midi, mxl])}/illustration.png"
"illustrationPath": f"/assets/{png_path}"
})
print(res.json())
+6 -36
View File
@@ -1,56 +1,26 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { useEffect, useRef, useState } from 'react';
import { useEffect, useRef } from 'react';
import { Slider, Switch, Text, View } from 'native-base';
import { Audio } from 'expo-av';
const MetronomeToggle = (props: { enabled: boolean, onToggle: (stateAfterToggle: boolean) => void }) => {
const [isEnabled, setEnabled] = useState(false);
useEffect(() => {
setEnabled(props.enabled)
}, [props.enabled])
return <Switch value={isEnabled} onToggle={() => {
console.log(isEnabled);
props.onToggle(!isEnabled);
setEnabled(!isEnabled);
}} />
}
export const Metronome = ({ paused = false, bpm }: { paused?: boolean; bpm: number }) => {
const audio = useRef<Audio.Sound | null>(null);
const ref = useRef<HTMLAudioElement | null>(null);
const enabled = useRef<boolean>(false);
const volume = useRef<number>(50);
useEffect(() => {
if (!enabled) {
return;
} else if (!audio.current) {
Audio.Sound.createAsync(require('../assets/metronome.mp3')).then((a) => {
audio.current = a.sound;
});
}
return () => {
audio.current?.unloadAsync();
};
}, [enabled]);
useEffect(() => {
if (paused) return;
const int = setInterval(() => {
if (!enabled.current) return;
if (!audio.current) return;
audio.current?.playAsync();
if (!ref.current) ref.current = new Audio('/assets/metronome.mp3');
ref.current.volume = volume.current / 100;
ref.current.play();
}, 60000 / bpm);
return () => clearInterval(int);
}, [bpm, paused]);
useEffect(() => {
audio.current?.setVolumeAsync(volume.current / 100);
}, [volume.current]);
return (
<View>
<Text>Metronome Settings</Text>
<Text>Enabled:</Text>
<MetronomeToggle enabled={enabled.current} onToggle={(e) => (enabled.current = e)} />
<Switch value={enabled.current} onToggle={() => (enabled.current = !enabled.current)} />
<Text>Volume:</Text>
<Slider
maxWidth={'500px'}
-1
View File
@@ -25,7 +25,6 @@
"@react-navigation/native-stack": "^6.9.14",
"@reduxjs/toolkit": "^1.9.6",
"expo": "~49.0.13",
"expo-av": "~13.4.1",
"expo-image-picker": "~14.3.2",
"expo-linear-gradient": "~12.3.0",
"expo-linking": "~5.0.2",
-5
View File
@@ -6056,11 +6056,6 @@ expo-asset@~8.10.1:
path-browserify "^1.0.0"
url-parse "^1.5.9"
expo-av@~13.4.1:
version "13.4.1"
resolved "https://registry.yarnpkg.com/expo-av/-/expo-av-13.4.1.tgz#83029b3202e64bf060f0a7a24591d93bf7ab728c"
integrity sha512-0K8QEFzZeNGrppzYUs8wOtjOyPPkxzlVYbEHM6WzIQOG1uYYNOJkJB3aQHVFXHmz+AzoHwMrUjcschofwaMNeg==
expo-constants@~14.4.2:
version "14.4.2"
resolved "https://registry.yarnpkg.com/expo-constants/-/expo-constants-14.4.2.tgz#cac5e8b524069545739b8d8595ce96cc5be6578c"