mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-09-02 01:24:33 +02:00
fix pitch analysis
This commit is contained in:
50
.github/workflows/deploy.yml
vendored
Normal file
50
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./dist
|
||||
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
10
src/App.tsx
10
src/App.tsx
@@ -12,8 +12,9 @@ import {
|
||||
getFirstPositionNotes,
|
||||
getFretboardPositions
|
||||
} from './music/Tunings';
|
||||
import { Mic, MicOff } from 'lucide-react';
|
||||
import { Mic, MicOff, SkipForward } from 'lucide-react';
|
||||
import './App.css';
|
||||
import './styles/skip-button.css';
|
||||
|
||||
const NOTE_MATCH_THRESHOLD_MS = 300; // How long to convert hold note to confirm
|
||||
|
||||
@@ -149,6 +150,13 @@ function App() {
|
||||
)}
|
||||
|
||||
{error && <div className="error-message">{error}</div>}
|
||||
|
||||
<div className="action-row" style={{ marginTop: '24px', display: 'flex', justifyContent: 'center' }}>
|
||||
<button className="skip-button" onClick={generateNewNote}>
|
||||
<SkipForward size={18} />
|
||||
Skip Note
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="pitch-monitor-bar">
|
||||
|
||||
@@ -58,9 +58,17 @@ export class PitchAnalyzer {
|
||||
}
|
||||
rms = Math.sqrt(rms / this.buffer.length);
|
||||
|
||||
if (rms < 0.01) return null; // Silence threshold
|
||||
if (rms < 0.05) return null; // Silence threshold increased to 0.05 for robustness because 0.01 picked up noise
|
||||
|
||||
const pitch = this.detector(this.buffer);
|
||||
|
||||
// Guitar range filtering:
|
||||
// Low E (E2) is ~82Hz. Drop D is ~73Hz.
|
||||
// High E (E4) is ~330Hz. 12th fret E5 is ~660Hz.
|
||||
// Harmonics can go higher, but unlikely above 1500Hz for fundamental training.
|
||||
// 19kHz (user reported D#10) is definitely noise.
|
||||
if (pitch && (pitch < 70 || pitch > 1500)) return null;
|
||||
|
||||
return pitch;
|
||||
}
|
||||
}
|
||||
|
||||
27
src/styles/skip-button.css
Normal file
27
src/styles/skip-button.css
Normal file
@@ -0,0 +1,27 @@
|
||||
/* App.css additions */
|
||||
|
||||
/* Skip Button */
|
||||
.skip-button {
|
||||
background: none;
|
||||
border: 2px solid var(--color-text-muted);
|
||||
color: var(--color-text-muted);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.skip-button:hover {
|
||||
border-color: var(--color-text-main);
|
||||
color: var(--color-text-main);
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.skip-button:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
@@ -4,4 +4,6 @@ import react from '@vitejs/plugin-react'
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
// IMPORTANT: Replace 'sheet-music-trainer' with your GitHub repository name
|
||||
base: '/sheetmusictrainer/',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user