This module provides some syntactic sugar over the AudioContext.createOscillator function
- Source:
 
Example
import { sine, square, master } from 'synth-kit'
master.start(sine('A4'))
master.start(square({ note: 'c3', detune: -10 }))
        
    
    Methods
(static) lfo(config)
Create an LFO (low frequency oscillator). It's a standard oscillator with some goodies to reduce the boilerplate code when used as signal modulator.
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Options | May include any of the  
  | 
        
- Source:
 - See:
 - 
        
- osc
 
 
Example
sine({ note: 'C4', detune: lfo({ freq: 5, amplitude: 50 }) })
sine({ note: 'A4', detune: lfo({ amplitude: 10, tempo: 120, division: 3 })
        
            
    
    (static) osc(config) → {AudioNode}
Create an oscillator (an OscillatorNode)
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Object | may include: 
 Notice that instead of a config object, this function also accepts a note name or a frequency value (see examples)  | 
        
- Source:
 
Returns:
the oscillator
- Type
 - AudioNode
 
Example
// basic usage
osc({ type: 'sine', frequency: 880 })
osc({ note: 'C4', type: 'square', detune: -10 })
// parameter modulation
osc({ freq: 1500, detune: osc({ freq: 20}) })
osc({ freq: envelope(...), type: 'square' })
// without configuration object
osc('C4')
osc(1200)
        
            
    
    (static) saw(config) → {AudioNode}
Create a sawtooth oscillator. An alias for osc({ type: 'sawtooth', ... })
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Object | Same as   | 
        
- Source:
 - See:
 - 
        
- osc
 
 
Returns:
the oscillator
- Type
 - AudioNode
 
Example
saw('A3')
saw({ freq: 440, detune: lfo(5, 10) })
        
            
    
    (static) sine(config) → {AudioNode}
Create a sine oscillator. An alias for osc({ type: 'sine', ... })
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Object | Same as   | 
        
- Source:
 - See:
 - 
        
- osc
 
 
Returns:
the oscillator
- Type
 - AudioNode
 
Example
sine('C4')
sine({ midi: 70, detune: -50 })
        
            
    
    (static) square(config) → {AudioNode}
Create a square oscillator. An alias for osc({ type: 'square', ... })
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Object | Same as   | 
        
- Source:
 - See:
 - 
        
- osc
 
 
Returns:
the oscillator
- Type
 - AudioNode
 
Example
square({ note: 'c#3', context: offline() })
        
            
    
    (static) triangle(config) → {AudioNode}
Create a triangle oscillator. An alias for osc({ type: 'triangle', ... })
Parameters:
| Name | Type | Description | 
|---|---|---|
config | 
            
            Object | Same as   | 
        
- Source:
 - See:
 - 
        
- osc
 
 
Returns:
the oscillator
- Type
 - AudioNode
 
Example
triangle({ note: 'Bb4', detune: -10 })