Skip to content

Commit

Permalink
1st version of bass + melody song type in song generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Modrigue committed Jan 8, 2024
1 parent 9c62ac2 commit dd031be
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 10 deletions.
3 changes: 2 additions & 1 deletion js/gui/interface.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/gui/interface.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/gui/strings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/gui/strings.js.map

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions js/song_generator/song_generator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/song_generator/song_generator.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions ts/gui/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,12 @@ function updateSelectors(resetScaleExplorer = false, resetScaleFinder = false, r
//(<HTMLSelectElement>document.getElementById(`song_generator_type`)).selectedIndex = 3;
updateNoteSelector(`song_generator_tonic`, 0, false);
const selectedTypeId = getSelectedSongType('song_generator_type');
const isBassMelody = (selectedTypeId == "bass+melody");
const isArpeggiosProg = (selectedTypeId == "arpeggios_progression");
const isSequence = (selectedTypeId == "sequence");
const isCounterpoint = selectedTypeId.startsWith("counterpoint");
updateScaleSelector(`song_generator_scale`, "7major_nat,1", true, (isSequence || isArpeggiosProg || isCounterpoint),
(isSequence || isArpeggiosProg), resetSongGeneration);
updateScaleSelector(`song_generator_scale`, "7major_nat,1", true, (isSequence || isArpeggiosProg || isBassMelody || isCounterpoint),
(isSequence || isBassMelody || isArpeggiosProg), resetSongGeneration);

if (resetSongGeneration)
resetGeneratedSong();
Expand Down
2 changes: 2 additions & 0 deletions ts/gui/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ stringsDict_int.set("arpeggios_progression", "Arpeggios progression");
stringsDict_int.set("audio_not_supported", "⚠ Audio features may not work with your browser ⚠\nYou can use either Chrome, Edge or Brave to enable audio on the website");
stringsDict_int.set("bass", "Bass");
stringsDict_int.set("bass_chord_explorer", "Bass:");
stringsDict_int.set("bass+melody", "Bass + melody");
stringsDict_int.set("chord", "Chord");
stringsDict_int.set("chord_explorer_nb_strings_max_text", "strings played");
stringsDict_int.set("chord_neapolitan", "Neapolitan chord:");
Expand Down Expand Up @@ -98,6 +99,7 @@ stringsDict_fr.set("arpeggios_progression", "Progression d'arpèges");
stringsDict_fr.set("audio_not_supported", "⚠ Les fonctionnalités audio pourraient ne pas marcher votre navigateur web ⚠\nVous pouvez utiliser Chrome, Edge ou Brave pour activer l'audio sur le site");
stringsDict_fr.set("bass", "Basse");
stringsDict_fr.set("bass_chord_explorer", "Basse :");
stringsDict_fr.set("bass+melody", "Basse + mélodie");
stringsDict_fr.set("chord", "Accord");
stringsDict_fr.set("chord_explorer_nb_strings_max_text", "cordes jouées");
stringsDict_fr.set("chord_neapolitan", "Accord napolitain :");
Expand Down
18 changes: 16 additions & 2 deletions ts/song_generator/song_generator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const generatedSongTypes: Map<string, string> = new Map<string, string>();
generatedSongTypes.set("chords+melody" , "chords+melody");
generatedSongTypes.set("bass+melody" , "bass+melody");
generatedSongTypes.set("chords_progression" , "chords_progression");
generatedSongTypes.set("arpeggios_progression" , "arpeggios_progression");
generatedSongTypes.set("sequence" , "sequence");
Expand Down Expand Up @@ -148,6 +149,13 @@ function generateNewTrack(trackIndex: number = 0 /* offset 1, 0 = all tracks */)
trackCandidate = GenerateChordsProgTrack(tonic, scaleValues, nbBars, 1, octaves[trackIndex - 1], frequencies[trackIndex - 1], qNote, trackIndex);
break;

case "bass+melody":
if (trackIndex == 1)
trackCandidate = GenerateMelodyTrack(tonic, scaleValues, nbBars, nbNotesPerBar, octaves[trackIndex - 1], frequencies[trackIndex - 1], qNote, trackIndex);
else
trackCandidate = GenerateChordsProgBassTrack(tonic, scaleValues, nbBars, 1, octaves[trackIndex - 1], frequencies[trackIndex - 1], qNote, trackIndex);
break;

case "chords_progression":
if (trackIndex == 1)
trackCandidate = GenerateChordsProgTrack(tonic, scaleValues, nbBars, 1, octaves[trackIndex - 1], frequencies[trackIndex - 1], qNote, trackIndex);
Expand Down Expand Up @@ -329,13 +337,14 @@ function updateSongGeneratorPage(): void
{
const isCounterpoint = selectedTypeId.startsWith("counterpoint");
const isChordsMelody = (selectedTypeId == "chords+melody");
const isBassMelody = (selectedTypeId == "bass+melody");
const isChordsProg = (selectedTypeId == "chords_progression");
const isArpeggiosProg = (selectedTypeId == "arpeggios_progression");
const isSequence = (selectedTypeId == "sequence");

setEnabled("song_generator_nb_notes_per_bar", (isSequence || isChordsMelody || isArpeggiosProg));
setEnabled("song_generator_nb_notes_per_bar", (isSequence || isChordsMelody || isBassMelody || isArpeggiosProg));
setEnabled("song_generator_generate_track2", !regexCounterpoint4_5S.test(selectedTypeId));
setEnabled(`song_generator_freq_track1`, (isSequence || isChordsMelody));
setEnabled(`song_generator_freq_track1`, (isSequence || isChordsMelody || isBassMelody));
setEnabled(`song_generator_freq_track2`, isSequence);

// update track texts
Expand All @@ -347,6 +356,11 @@ function updateSongGeneratorPage(): void
track1Text.innerText = getString("melody");
track2Text.innerText = getString("chords");
}
else if (isBassMelody)
{
track1Text.innerText = getString("melody");
track2Text.innerText = getString("bass");
}
else if (isChordsProg)
{
track1Text.innerText = getString("chords");
Expand Down

0 comments on commit dd031be

Please sign in to comment.