-
Notifications
You must be signed in to change notification settings - Fork 88
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
Chord block and custom sound effect block #1289
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8e294ac
Merge branch 'master' into new_sound_lib
alexjsmac f700ff2
Add chord block
alexjsmac 0e4ab61
Merge remote-tracking branch 'upstream/master' into new_sound_lib
alexjsmac 3840027
Rename some things for clarity
alexjsmac 954eb70
Chord blocks supports notes in different octaves
alexjsmac 4983fe9
Song example
alexjsmac a3f9445
Merge branch 'master' of https://github.com/waterbearlang/waterbear i…
alexjsmac ece5f6e
Merge branch 'new_sound_lib' of https://github.com/amaclean199/waterb…
alexjsmac 760191f
Fix app.js merge conflict with examples
alexjsmac d993eec
Merge branch 'new_sound_lib' of github.com:amaclean199/waterbear into…
alexjsmac 7284cd2
Merging conflict fix for list of examples in app.js
alexjsmac 974de9b
Tests for sound blocks
alexjsmac 33687a7
Removed the log from the playNotes block and alert from the keys block
alexjsmac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1004,7 +1004,7 @@ | |
var audio = T("audio", {load:file}); | ||
return audio; | ||
}, | ||
playNote: function(note, octave, beats){ | ||
addNote: function(note, octave, beats){ | ||
switch(note){ | ||
case "A": | ||
note = "a"; | ||
|
@@ -1083,35 +1083,92 @@ | |
var newNote = note + length; | ||
song += newNote; | ||
}, | ||
playChord: function(){ | ||
var args = [].slice.call(arguments) | ||
var oscenv = args[0]; | ||
var freqs = [] | ||
for (var i = 1; i < args.length; i++) { | ||
var freq; | ||
switch(args[i]){ | ||
case "A": | ||
freq = 55.000; | ||
break; | ||
case "A#/Bb": | ||
freq = 58.270; | ||
break; | ||
case "B": | ||
freq = 61.735; | ||
break; | ||
case "C": | ||
freq = 65.406; | ||
break; | ||
case "C#/Db": | ||
freq = 69.296; | ||
break; | ||
case "D": | ||
freq = 73.416; | ||
break; | ||
case "D#/Eb": | ||
freq = 77.782; | ||
break; | ||
case "E": | ||
freq = 82.407; | ||
break; | ||
case "F": | ||
freq = 87.307; | ||
break; | ||
case "F#/Gb": | ||
freq = 92.499; | ||
break; | ||
case "G": | ||
freq = 97.999; | ||
break; | ||
case "G#/Ab": | ||
freq = 103.826; | ||
break; | ||
} | ||
var octave = args[++i]; | ||
parseInt(octave); | ||
freq = freq * Math.pow(2, octave-1); | ||
freqs.push(freq); | ||
} | ||
T("interval", {interval:"L4", timeout:"L4"}, function() { | ||
for (var i = 0; i < freqs.length; i++) { | ||
oscenv.noteOnWithFreq(freqs[i], 64); | ||
} | ||
}).on("ended", function() { | ||
this.stop(); | ||
}).set({buddies:oscenv}).start(); | ||
}, | ||
playAudio: function(audio){ | ||
audio.play(); | ||
if (audio){ | ||
audio.play(); | ||
} | ||
}, | ||
playInstrument: function(sound){ | ||
playNotes: function(sound){ | ||
console.log(song); | ||
T("mml", {mml:song}, sound).on("ended", function() { | ||
sound.pause(); | ||
this.stop(); | ||
}).start(); | ||
song = "o4 l4 V12 "; | ||
}, | ||
mml: function(sound, mml){ | ||
playMML: function(sound, mml){ | ||
var gen = T("OscGen", {wave:sound, env:{type:"perc"}, mul:0.25}).play(); | ||
T("mml", {mml:mml}, gen).on("ended", function() { | ||
gen.pause(); | ||
this.stop(); | ||
}).start(); | ||
}, | ||
tempo: function(tempo){ | ||
tempoChange: function(tempo){ | ||
song += ("t" + tempo + " "); | ||
}, | ||
pause: function(sound){ | ||
if (assets.sounds[sound.name]){ | ||
assets.sounds[sound.name].pause(); | ||
pauseAudio: function(audio){ | ||
if (audio){ | ||
audio.pause(); | ||
} | ||
}, | ||
keys: function(wave, vol){ | ||
var synth = T("OscGen", {wave:wave, mul:vol}).play(); | ||
|
||
keys: function(synth){ | ||
var keydict = T("ndict.key"); | ||
var midicps = T("midicps"); | ||
T("keyboard").on("keydown", function(e) { | ||
|
@@ -1126,10 +1183,9 @@ | |
synth.noteOff(midi, 100); | ||
} | ||
}).start(); | ||
|
||
alert("Play notes on the keyboard"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still not happy with having an alert here. Let's create another issue to deal with this better. |
||
}, | ||
effect: function(effect){ | ||
soundEffect: function(effect){ | ||
switch(effect) { | ||
case "laser": | ||
var table = [1760, [110, "200ms"]]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pull out the console logging?