Navigation Menu

Skip to content

Commit

Permalink
added bass
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgovea committed Aug 31, 2011
1 parent 1661c1a commit db5496a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 28 deletions.
37 changes: 27 additions & 10 deletions public/javascripts/phon.js

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

27 changes: 22 additions & 5 deletions src/automation.coffee
Expand Up @@ -284,9 +284,14 @@ init = ->
log notes
for note in notes
if note.type is "Lead" && leadCount < 4
leads[leadCount].frequency = Note.fromLatin(note.pitch.toUpperCase()+'4').frequency()
leads[leadCount].frequency = Note.fromLatin(note.pitch).frequency()
log note
leadCount++
else if note.type is "Bass" && bassCount < 3
bass[bassCount].frequency = Note.fromLatin(note.pitch).frequency()
bassCount++
else if note.type is "Drum"
drum1.noteOn(440)

return {
leads: leadCount
Expand All @@ -309,10 +314,18 @@ init = ->

for lead in [0...enabled.leads]
leads[lead].generate()
smpl += leads[lead].getMix()
smpl += leads[lead].getMix() / (enabled.leads+2)

basmpl = 0
for b in [0...enabled.bass]
bass[b].generate()
basmpl += bass[b].getMix() / (enabled.bass+2)

drum1.generate()
for n in [0...channelCount]
buf[i+n] = smpl
smpl += drum1.getMix n
smpl += comb[n].pushSample basmpl
buf[i+n] = comp.pushSample smpl



Expand All @@ -326,15 +339,19 @@ init = ->




sample = audioLib.PCMData.decode(atob(freeverb.sample));
dev = audioLib.AudioDevice(fillBuffer, 2)
sampleRate = dev.sampleRate
noteLength = sampleRate * 0.001 * 200
reverb = new audioLib.Reverb(sampleRate, 2)
comb = [new audioLib.CombFilter(sampleRate, 500, 0.5, 0.6),new audioLib.CombFilter(sampleRate, 900, 0.6, 0.4)]
drum1 = new audioLib.Sampler(sampleRate)
drum1.load(sample, (if sampleRate is 44100 then false else true));
drum2 = new audioLib.Sampler(sampleRate)
leads = [new audioLib.Oscillator(sampleRate, 440),new audioLib.Oscillator(sampleRate, 440),new audioLib.Oscillator(sampleRate, 440),new audioLib.Oscillator(sampleRate, 440)]
leads[0].waveShape = leads[1].waveShape = leads[2].waveShape = leads[3].waveShape = 'sawtooth'
bass = [new audioLib.Oscillator(sampleRate, 440),new audioLib.Oscillator(sampleRate, 440),new audioLib.Oscillator(sampleRate, 440)]
#bass[0].waveShape = bass[1].waveShape = bass[2].waveShape = 'square'
comp = new audioLib.Compressor sampleRate



Expand Down
2 changes: 1 addition & 1 deletion src/sidebar.coffee
Expand Up @@ -19,7 +19,7 @@ $ ->
refresh_gui: ->
sound = @get 'sound'
gui = new DAT.GUI
gui.add(sound.attributes, 'pitch').options('a', 'a#', 'b', 'c','c#','d','d#','e', 'f', 'f#', 'g')
gui.add(sound.attributes, 'pitch').options("C3", "C#3", "D3", "D#3", "E3", "F3", "F#3", "G3", "A3", "A#3", "B3", "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "A4", "A#4", "B4", "C5")
gui.add(sound.attributes, 'length').min(0).max(100)
@gui_elements = [gui.domElement]

Expand Down
4 changes: 2 additions & 2 deletions src/sounds.coffee
Expand Up @@ -17,13 +17,13 @@ Sound = class extends Backbone.Model
Phon.Sounds.Lead = class extends Sound
defaults:
type: 'Lead'
pitch: 'a'
pitch: 'C4'
length: 0

Phon.Sounds.Bass = class extends Sound
defaults:
type: 'Bass'
pitch: 'a'
pitch: 'C4'
length: 0

Phon.Sounds.Drum = class extends Sound
Expand Down
20 changes: 10 additions & 10 deletions views/index.jade
Expand Up @@ -6,17 +6,17 @@
h2.clearfix Lead
span.icon
.content
//
.module(data-module='Instrument', data-sound='Bass')
h2.clearfix Bass
span.icon
.content
.module(data-module='Sample', data-sound='Drum')
h2.clearfix Drums
span.icon
.content

.module(data-module='Instrument', data-sound='Bass')
h2.clearfix Bass
span.icon
.content

.module(data-module='Sample', data-sound='Drum')
h2.clearfix Drums
span.icon
.content
//
.module.last(data-module='Sample', data-sound='Sample')
h2.clearfix Samples
span.icon
Expand Down
1 change: 1 addition & 0 deletions views/layout.jade
Expand Up @@ -11,5 +11,6 @@ html
script(src='/javascripts/lib/audiolib.js')
script(src='/javascripts/lib/music.js')
script(src='/socket.io/socket.io.js')
script(src='/javascripts/freeverb.js')
script(src='/javascripts/phon.js')
body!= body

0 comments on commit db5496a

Please sign in to comment.