Skip to content

Commit

Permalink
Rename project
Browse files Browse the repository at this point in the history
  • Loading branch information
ZaneH committed Jul 7, 2022
1 parent e1dd328 commit bddee9a
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 78 deletions.
73 changes: 24 additions & 49 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,42 @@


# Copyright 2019-2021 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

name: updater test artifacts
name: 'publish'
on:
pull_request:
paths:
- '.github/workflows/artifacts-updater.yml'
- 'core/tauri/**'
- 'tooling/cli.rs/**'
- 'tooling/bundler/**'
- 'examples/updater/**'
push:
branches:
- release

jobs:
build-artifacs:
runs-on: ${{ matrix.platform }}

publish-tauri:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: install stable
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 16
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install webkit2gtk (ubuntu only)
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- run: cargo install --path ./tooling/cli.rs --force
- name: install cli deps via yarn
working-directory: ./tooling/cli.js
run: yarn
- name: build cli
working-directory: ./tooling/cli.js
run: yarn build
- name: build sample artifacts (updater)
working-directory: ./examples/updater
run: |
yarn install
node ../../tooling/cli.js/bin/tauri build
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libasound2-dev libudev-dev pkg-config
- name: install app dependencies and build it
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
- uses: actions/upload-artifact@v2
if: matrix.platform == 'ubuntu-latest'
with:
name: linux-updater-artifacts
path: ./target/release/bundle/appimage/updater-example_*.AppImage.*

- uses: actions/upload-artifact@v2
if: matrix.platform == 'windows-latest'
with:
name: windows-updater-artifacts
path: ./target/release/bundle/msi/*

- uses: actions/upload-artifact@v2
if: matrix.platform == 'macos-latest'
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
name: macos-updater-artifacts
path: ./target/release/bundle/macos/updater-example_*.app.tar.*
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: 'Piano Trainer v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: false
prerelease: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Scale Trainer
# Piano Trainer

A cross-platform utility for learning the piano

Expand Down
12 changes: 6 additions & 6 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"distDir": "../build"
},
"package": {
"productName": "scale-trainer",
"version": "0.1.0"
"productName": "Piano Trainer",
"version": "1.0.0"
},
"tauri": {
"allowlist": {
Expand All @@ -29,7 +29,7 @@
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.zane.scale-trainer",
"identifier": "com.zane.piano-trainer",
"longDescription": "",
"macOS": {
"entitlements": null,
Expand All @@ -39,7 +39,7 @@
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"shortDescription": "A MIDI utility for learning scales, chords, and more!",
"targets": "all",
"windows": {
"certificateThumbprint": null,
Expand All @@ -55,15 +55,15 @@
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDI5ODJFNDA4ODM4NkY4QjAKUldTdytJYURDT1NDS1FZV0lUS3doQURibmtaRGZqUzJxUmI3UzBXY0JxK1drcCtNLy92bUpEaVoK",
"endpoints": [
"https://gist.githubusercontent.com/ZaneH/76ddde809ccd22c0ff77f2bd268c8293/raw/691f634e45be4d7cf1695a52903b2597bc1db41d/update-metadata.json"
"https://gist.github.com/ZaneH/2075e77e36940b6aebae001648a40e5b/raw"
]
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "Scale Trainer",
"title": "Piano Trainer",
"width": 800
}
]
Expand Down
11 changes: 10 additions & 1 deletion src/components/Keyboard/Keyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Keyboard = () => {
const matches = targetChord.every((e) => chordStack?.includes(e))
if (matches) {
setNoteCounter?.((nc) => nc + 1)
setChordStack?.([])
}
} else if (practiceMode === 'fifths') {
const targetFifths = [
Expand All @@ -83,9 +84,17 @@ const Keyboard = () => {
const matches = targetFifths.every((e) => chordStack?.includes(e))
if (matches) {
setNoteCounter?.((nc) => nc + 1)
setChordStack?.([])
}
}
}, [chordStack, nextTargetNote, scale, practiceMode, setNoteCounter])
}, [
chordStack,
nextTargetNote,
scale,
practiceMode,
setNoteCounter,
setChordStack,
])

useEffect(() => {
const unlisten = async () => {
Expand Down
39 changes: 21 additions & 18 deletions src/components/SoundfontProvider/SoundfontProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Based on SoundfontProvider
// https://github.com/kevinsqi/react-piano/blob/master/demo/src/SoundfontProvider.js
import { useEffect, useMemo, useState } from 'react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import Soundfont, { InstrumentName, Player } from 'soundfont-player'

interface SoundfontProviderProps {
Expand Down Expand Up @@ -35,10 +35,6 @@ const SoundfontProvider = ({
[]
)

useEffect(() => {
loadInstrument(instrumentName)?.then((i) => setInstrument(i))
}, [])

const playNote = (midiNumber: string) => {
resumeAudio().then(() => {
const audioNode = instrument?.play(midiNumber)
Expand Down Expand Up @@ -72,20 +68,27 @@ const SoundfontProvider = ({
}
}

const loadInstrument = (name: InstrumentName) => {
if (!audioContext) {
console.error("Couldn't create an audio context")
return
}
const loadInstrument = useCallback(
(name: InstrumentName) => {
if (!audioContext) {
console.error("Couldn't create an audio context")
return
}

return Soundfont.instrument(audioContext, name, {
format,
soundfont,
nameToUrl: (name: string, soundfont: any, format: string) => {
return `${hostname}/${soundfont}/${name}-${format}.js`
},
})
}
return Soundfont.instrument(audioContext, name, {
format,
soundfont,
nameToUrl: (name: string, soundfont: any, format: string) => {
return `${hostname}/${soundfont}/${name}-${format}.js`
},
})
},
[audioContext, format, hostname, soundfont]
)

useEffect(() => {
loadInstrument(instrumentName)?.then((i) => setInstrument(i))
}, [instrumentName, loadInstrument])

return render({ playNote, stopNote })
}
Expand Down
31 changes: 28 additions & 3 deletions src/components/TrainerProvider/TrainerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,31 @@ const TrainerProvider: FC<TrainerContextType> = ({ children }) => {
useEffect(() => {
setPrevNote(nextTargetNote)

// TODO: Rework this logic. It's buggy
if (isScalePingPong && _isGoingDown) {
// don't reverse if we're on the first note ever pressed
if (noteCounter === 0) {
setNextTargetNote(
Number(Object.keys(scale.keys)[noteCounter % SCALE_LENGTH])
)
} else {
setNextTargetNote(
Number(Object.keys(scale.keys).reverse()[noteCounter % SCALE_LENGTH])
)
}

if ((noteCounter + 1) % SCALE_LENGTH === 0) {
_setIsGoingDown(false)
setNoteCounter((nc) => nc + 1)
}
} else if (isScalePingPong) {
setNextTargetNote(
Number(Object.keys(scale.keys).reverse()[noteCounter % SCALE_LENGTH])
Number(Object.keys(scale.keys)[noteCounter % SCALE_LENGTH])
)

if ((noteCounter + 1) % SCALE_LENGTH === 0) {
_setIsGoingDown(false)
_setIsGoingDown(true)
setNoteCounter((nc) => nc + 1)
}
} else {
setNextTargetNote(
Expand All @@ -103,7 +121,14 @@ const TrainerProvider: FC<TrainerContextType> = ({ children }) => {
_setIsGoingDown(true)
}
}
}, [noteCounter, setNextTargetNote, scale, isScalePingPong])
}, [
noteCounter,
setNextTargetNote,
scale,
isScalePingPong,
nextTargetNote,
_isGoingDown,
])

useEffect(() => {
setNoteCounter(0)
Expand Down

0 comments on commit bddee9a

Please sign in to comment.