Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a button to the playback that toggles treble voice #907

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function handleFlats (inputStr){

///////////////////////////////////////////////////////////////////////////////////
//Plays the volpiano notes using MIDI.js
function volpiano2midi(input_arr, note_dur) {
function volpiano2midi(input_arr, note_dur, treble_voice = false) {

//construct dictionary with pitch values
var pitch_dict = {};
Expand Down Expand Up @@ -127,6 +127,11 @@ function volpiano2midi(input_arr, note_dur) {
pitch_dict['t'] = 46; // make-shift Bb3
pitch_dict['u'] = 58; // make-shift Bb4
pitch_dict['v'] = 50; // make-shift Bb5
if (treble_voice) {
for (var key in pitch_dict) {
pitch_dict[key] += 12;
}
}

// create array of volpiano characters representing barlines
// for purposes of midi playback, these are treated as rests
Expand Down Expand Up @@ -252,21 +257,27 @@ export default Marionette.ItemView.extend({
ui : {
volpianoSyllables: ".volpiano-syllable",
btnPlay: ".btnPlay",
btnStop: ".btnStop"
btnStop: ".btnStop",
btnTreble: ".btnTreble"
},
events: {
"click .btnPlay": "submit",
"click .btnStop": "stop"
"click .btnStop": "stop",
"click .btnTreble": "toggleTreble"
},
submit: function mainPlay() {
var volArr = parse_volpiano(this.ui.volpianoSyllables);
this.ui.btnPlay.html("Playing...");
this.ui.btnPlay.attr("disabled", true);
volpiano2midi(volArr, .6);
volpiano2midi(volArr, .6, this.treble_voice);
},
stop: function(){
audioStopReset(MIDI);
},
toggleTreble: function(){
this.treble_voice = !this.treble_voice;
this.ui.btnTreble.html(this.treble_voice ? "Treble On" : "Treble Off");
},
stopChantAudio: function(){
if (MIDI.getContext().state === "running"){
audioStopReset(MIDI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ <h5>Full Text</h5>
<hr/>
<button class="btnPlay">Play Audio</button>
<button class="btnStop">Stop Audio</button>
<button class="btnTreble">Toggle Treble Voice</button>
<% } %>
Loading