Skip to content

Commit

Permalink
Zero latency
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Oct 11, 2024
1 parent 540c1e1 commit fcd8e12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/components/piano/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useEffect, useState, useRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { DEFAULT_ENVELOPE, INSTRUMENTS, LATENCY } from '../../constants';
import { DEFAULT_ENVELOPE, INSTRUMENTS } from '../../constants';
import { KEYBOARD_LAYOUTS } from '../../keyboard-layout';
import Loading from '../loading';
import Keyboard from '../keyboard';
Expand Down Expand Up @@ -137,7 +137,7 @@ const Piano = ( { settings, onChange }: Props ) => {
targetKey.octave + octaveOffset + instrumentOctaveOffset
}`;

piano.triggerAttack( targetNote, piano.context.currentTime + LATENCY );
piano.triggerAttack( targetNote, piano.context.currentTime );
setActiveKeys( [ ...activeKeys, targetKey ] );
};

Expand Down Expand Up @@ -177,7 +177,7 @@ const Piano = ( { settings, onChange }: Props ) => {
const targetNote = `${ note }${ octave + octaveOffset + instrumentOctaveOffset }`;

if ( useSustainPedal && instrument !== 'synthesizer' ) {
piano.triggerAttack( targetNote, piano.context.currentTime + LATENCY );
piano.triggerAttack( targetNote, piano.context.currentTime );
} else {
piano.triggerAttackRelease( targetNote, 0.2 );
}
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface BlockAttributes {
keyIndicator: string;
}

export const LATENCY = 0.01 as const;
export const MIN_VOLUME = -10 as const;
export const MAX_VOLUME = 5 as const;
export const DEFAULT_INSTRUMENT = 'acoustic-piano' as const;
Expand Down

0 comments on commit fcd8e12

Please sign in to comment.