Skip to content

Commit

Permalink
[FIX] Sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarrc committed Jul 26, 2024
1 parent 3688231 commit 7c1dd04
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/components/layout/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useSequencer } from "../../hooks/useSequencer";

const Display = () => {
const { enabled, input, output, passthrough, octave, playNote, stopAll } = useMidi();
const { bank, bankNames, state, sendControlChange } = useNTS();
const { bank, bankNames, setBank } = useNTS();
const { step, steps, setStep, bars, setBars, isPlaying, setIsPlaying, isRecording, setIsRecording, tempo, sequence, setSequence, barLength } = useSequencer();
const [ message, setMessage ] = useState(null);
const [ bpmIndicator, setBpmIndicator ] = useState(1)
Expand Down Expand Up @@ -41,22 +41,15 @@ const Display = () => {
let duration = step.length * 60000/tempo;

if(!step?.note) return;
if(!isNaN(step?.bank) && step.bank !== bank) {
let b = JSON.parse(localStorage.getItem(`BANK_${step.bank}`))
if(!b) return;
Object.keys(b).forEach(cc => sendControlChange(parseInt(cc), b[cc]));
};
if(!isNaN(step?.bank)) setBank(step.bank);

playNote(step.note, true, false, duration);
}, [bank, playNote, sendControlChange, tempo])
}, [bank, playNote, tempo])

const togglePlay = () => {
window.navigator.vibrate && window.navigator.vibrate(10);

if(isPlaying){
Object.keys(state).forEach(cc => sendControlChange(parseInt(cc), state[cc]));
}

if(isPlaying) setBank(step.bank);
setIsPlaying(p => !p);
}

Expand Down

0 comments on commit 7c1dd04

Please sign in to comment.