Skip to content

Commit

Permalink
added initial low tom integration
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonypetersen committed Nov 9, 2023
1 parent 36ca031 commit e74d01c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/pages/cubes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const cube_player = () => {
...state.getState().cubeFill[0].tickables
];


play(groove);
}

Expand Down Expand Up @@ -97,6 +96,8 @@ const play = (groove) => {
return state.getState().hiHatBuffer;
case constants.RACK:
return state.getState().midTomBuffer;
case constants.FLOOR:
return state.getState().lowTomBuffer;
default:
return null; // Return null or undefined if there's no buffer for the note
}
Expand Down
11 changes: 8 additions & 3 deletions src/shared/audio.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { state } from './common.js';
let kickBuffer, snareBuffer, ghostBuffer, hiHatBuffer, midTomBuffer;
let kickBuffer, snareBuffer, ghostBuffer, hiHatBuffer, midTomBuffer, lowTomBuffer;

export const audio_driver = () => {
Promise.all([
loadAudioFile('audio/kick.wav').then(buffer => { kickBuffer = buffer; }),
loadAudioFile('audio/snare.wav').then(buffer => { snareBuffer = buffer; }),
loadAudioFile('audio/ghost.wav').then(buffer => { ghostBuffer = buffer; }),
loadAudioFile('audio/hihat.wav').then(buffer => { hiHatBuffer = buffer; }),
loadAudioFile('audio/midtom.wav').then(buffer => { midTomBuffer = buffer; })
loadAudioFile('audio/midtom.wav').then(buffer => { midTomBuffer = buffer; }),
loadAudioFile('audio/lotom.wav').then(buffer => { lowTomBuffer = buffer; })
]).then(() => {
state.updateState({ kickBuffer, snareBuffer, ghostBuffer, hiHatBuffer, midTomBuffer });
state.updateState({ kickBuffer, snareBuffer, ghostBuffer, hiHatBuffer, midTomBuffer, lowTomBuffer });
console.log('All audio files preloaded');
});
}
Expand Down Expand Up @@ -50,4 +51,8 @@ export const hiHat = () => {

export const midTom = () => {
playBuffer(midTomBuffer);
}

export const lowTom = () => {
playBuffer(lowTomBuffer);
}
19 changes: 15 additions & 4 deletions src/shared/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const showGroove = (groove) => {
// drawVerticalLines(ctx, canvas);
}

const translate = (notation) => {
const translate = (notation, flag = false) => {

const dotted = (staveNote, noteIndex = -1) => {
if (noteIndex < 0) {
Expand Down Expand Up @@ -294,7 +294,12 @@ const translate = (notation) => {
if(notation.fill) {
if(notation.fill[i]) {
pattern += "1";
note.push(constants.RACK);
if(flag) {
note.push(constants.RACK);
}
else {
note.push(constants.FLOOR);
}
notes.push(note);
}
else {
Expand Down Expand Up @@ -463,8 +468,14 @@ export const transcribe = (notation, type) => {
if(type === "fill") {
notationSplit.fill = notation.fill.slice(i * 4, (i + 1) * 4);
}

translation.push(translate(notationSplit));
if(i == 0 || i == 1) {
translation.push(translate(notationSplit, true));

}
else {
translation.push(translate(notationSplit));

}
}

return translation;
Expand Down

0 comments on commit e74d01c

Please sign in to comment.