Documentation ¶
Index ¶
- func InterpLinear16(y1, y2, mu float64) int16
- func Println(a ...interface{})
- func RunApp()
- type Config
- type Controls
- func (c *Controls) CalcAmp(key int, velocity, rms float64) float32
- func (c *Controls) CalcPan(key int) float32
- func (c *Controls) LoadDefaults()
- func (c *Controls) LoadFrom(path string) error
- func (c *Controls) LoadMidiConfig() error
- func (c *Controls) Print()
- func (c *Controls) ProcessCommand(cmd string)
- func (c *Controls) ProcessMidi(num int32, value float64)
- func (c *Controls) Run()
- func (c *Controls) UpdateAmp(x float64)
- func (c *Controls) UpdateCropThresh(x float64)
- func (c *Controls) UpdateGammaAmp(x float64)
- func (c *Controls) UpdateGammaLayer(x float64)
- func (c *Controls) UpdateMixLayers(x float64)
- func (c *Controls) UpdatePanHigh(x float64)
- func (c *Controls) UpdatePanLow(x float64)
- func (c *Controls) UpdatePitchBendMax(x float64)
- func (c *Controls) UpdateRmsHigh(x float64)
- func (c *Controls) UpdateRmsLow(x float64)
- func (c *Controls) UpdateRmsTime(x float64)
- func (c *Controls) UpdateSustain(x float64)
- func (c *Controls) UpdateTau(x float64)
- func (c *Controls) UpdateTauCut(x float64)
- func (c *Controls) UpdateTauFadeIn(x float64)
- func (c *Controls) UpdateTranspose(x float64)
- func (c *Controls) UpdateVelMult(x float64)
- type KeySampler
- func (ks *KeySampler) AddLayer()
- func (ks *KeySampler) AddSample(sample *Sample, layer int)
- func (ks *KeySampler) BorrowFrom(ks2 *KeySampler) error
- func (ks *KeySampler) Copy() *KeySampler
- func (ks *KeySampler) HasData() bool
- func (ks *KeySampler) NoteOff()
- func (ks *KeySampler) NoteOn(velocity float64)
- func (ks *KeySampler) NumLayers() int
- func (ks *KeySampler) Transpose(trans int) *KeySampler
- func (ks *KeySampler) UpdateCropThresh(thresh float64)
- func (ks *KeySampler) UpdateRms(rmsTime float64)
- func (ks *KeySampler) WriteOutput(buf *Sound, amp, di []float32)
- type MidiListener
- type PlayingSample
- type Sample
- type SampleLayer
- func (sl *SampleLayer) AddSample(sample *Sample)
- func (sl *SampleLayer) BorrowFrom(sl2 *SampleLayer, semitones int)
- func (sl *SampleLayer) Copy() *SampleLayer
- func (sl *SampleLayer) GetSample(idx int) (int, *Sample)
- func (sl *SampleLayer) NumSamples() int
- func (sl *SampleLayer) Transpose(trans int) *SampleLayer
- func (sl *SampleLayer) UpdateCropThresh(thresh float64)
- func (sl *SampleLayer) UpdateRms(rmsTime float64)
- type Sampler
- func (s *Sampler) ControllerEvent(control int32, value float64)
- func (s *Sampler) JackProcess(bufIn, bufOut [][]float32) error
- func (s *Sampler) NoteOffEvent(note int8, value float64)
- func (s *Sampler) NoteOnEvent(note int8, value float64)
- func (s *Sampler) PitchBendEvent(value float64)
- func (s *Sampler) Run()
- func (s *Sampler) UpdateCropThresh()
- func (s *Sampler) UpdateRms()
- type Sound
- type TuningFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InterpLinear16 ¶
See http://paulbourke.net/miscellaneous/interpolation/. Using nearest neighbor instead of linear interpolation sounds aweful. After trying several interpolation methods, inclusing cubic, cosine, and hermite polynomials, I've found linear interpolation to sound the best for the small rate changes we're making.
Of course it's always possible that I had an error somewhere.
Types ¶
type Config ¶
type Config struct {
MidiIn string // Controller midi port (keyboard).
}
func LoadConfig ¶
type Controls ¶
type Controls struct { NFadeIn float32 // Fade-in length in samples. Computed from TauFadeIn. Transpose int8 // Added to midi note on input. PitchBendMax int8 // Maximum pitch bend in semitones. RRBorrow int8 // Distance to borrow round-robbin samples. Tau float64 // Key-up decay time constant. TauCut float64 // Key-repeat or cut decay time constant. TauFadeIn float64 // Sample fade in time. Amp float64 // Amplification multiplier. CropThresh float64 // Cut beginning of samples below this threshold. RmsTime float64 // Time period to use to compute sample RMS. RmsLow float64 // RMS for key 21 (Low A). RmsHigh float64 // RMS for key 108 (High C). PanLow float64 // Panning for key 21. -1 is left, 1 is right. PanHigh float64 // Panning for key 108. GammaAmp float64 // Amplitude scaling x^gamma. GammaLayer float64 // Layer scaling. VelMult float64 // Velocity multiplier. MixLayers bool // It True, mix layers together. FakeLayerRC bool // Use RC filter to construct fake zero-layer. Sustain bool // Sustain pedal value (0-1). // contains filtered or unexported fields }
----------------------------------------------------------------------------
func NewControls ¶
func (*Controls) LoadDefaults ¶
func (c *Controls) LoadDefaults()
func (*Controls) LoadMidiConfig ¶
func (*Controls) ProcessCommand ¶
func (*Controls) ProcessMidi ¶
func (*Controls) UpdateCropThresh ¶
func (*Controls) UpdateGammaAmp ¶
func (*Controls) UpdateGammaLayer ¶
func (*Controls) UpdateMixLayers ¶
func (*Controls) UpdatePanHigh ¶
func (*Controls) UpdatePanLow ¶
func (*Controls) UpdatePitchBendMax ¶
func (*Controls) UpdateRmsHigh ¶
func (*Controls) UpdateRmsLow ¶
func (*Controls) UpdateRmsTime ¶
func (*Controls) UpdateSustain ¶
func (*Controls) UpdateTauCut ¶
func (*Controls) UpdateTauFadeIn ¶
func (*Controls) UpdateTranspose ¶
---------------------------------------------------------------------------- Update functions, one for each control.
func (*Controls) UpdateVelMult ¶
type KeySampler ¶
type KeySampler struct { Key int // The midi key number. // contains filtered or unexported fields }
----------------------------------------------------------------------------
func NewKeySampler ¶
func NewKeySampler(controls *Controls, key int) *KeySampler
func (*KeySampler) AddLayer ¶
func (ks *KeySampler) AddLayer()
func (*KeySampler) AddSample ¶
func (ks *KeySampler) AddSample(sample *Sample, layer int)
func (*KeySampler) BorrowFrom ¶
func (ks *KeySampler) BorrowFrom(ks2 *KeySampler) error
func (*KeySampler) Copy ¶
func (ks *KeySampler) Copy() *KeySampler
func (*KeySampler) HasData ¶
func (ks *KeySampler) HasData() bool
func (*KeySampler) NoteOff ¶
func (ks *KeySampler) NoteOff()
func (*KeySampler) NoteOn ¶
func (ks *KeySampler) NoteOn(velocity float64)
func (*KeySampler) NumLayers ¶
func (ks *KeySampler) NumLayers() int
func (*KeySampler) Transpose ¶
func (ks *KeySampler) Transpose(trans int) *KeySampler
func (*KeySampler) UpdateCropThresh ¶
func (ks *KeySampler) UpdateCropThresh(thresh float64)
func (*KeySampler) UpdateRms ¶
func (ks *KeySampler) UpdateRms(rmsTime float64)
func (*KeySampler) WriteOutput ¶
func (ks *KeySampler) WriteOutput(buf *Sound, amp, di []float32)
type MidiListener ¶
type MidiListener struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------
func NewMidiListener ¶
func NewMidiListener( sampler *Sampler, name, midiIn string) (*MidiListener, error)
NewMidiListener * name : The name of the device. * midiPort : An incoming midi port to connect to.
func (*MidiListener) Run ¶
func (ml *MidiListener) Run()
Run * Read incoming midi events and send them to the sampler.
type PlayingSample ¶
type PlayingSample struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------
func NewPlayingSample ¶
func NewPlayingSample( controls *Controls, sample1, sample2 *Sample, amp1, amp2, pan, mix float32) *PlayingSample
NewPlayingSample: If not mixing layers, then mix should be 0, and amp2 is ignored.
func (*PlayingSample) WriteOutput ¶
func (ps *PlayingSample) WriteOutput(buf *Sound, amp, di []float32) bool
type Sample ¶
type Sample struct { Rms float64 // The RMS value of the initial samples. Idx0 int // Zero index. Len int // Number of samples in each channel. L []int16 // Left channel samples. R []int16 // Right channel samples. }
----------------------------------------------------------------------------
func NewSampleFromArrays ¶
func (*Sample) FakeLayerRC ¶
func (*Sample) Interp ¶
Return interpolated L and R samples for the given index. Samples are scaled to 1.0 max.
func (*Sample) UpdateCropThresh ¶
type SampleLayer ¶
type SampleLayer struct {
// contains filtered or unexported fields
}
----------------------------------------------------------------------------
func (*SampleLayer) AddSample ¶
func (sl *SampleLayer) AddSample(sample *Sample)
func (*SampleLayer) BorrowFrom ¶
func (sl *SampleLayer) BorrowFrom(sl2 *SampleLayer, semitones int)
func (*SampleLayer) Copy ¶
func (sl *SampleLayer) Copy() *SampleLayer
func (*SampleLayer) GetSample ¶
func (sl *SampleLayer) GetSample(idx int) (int, *Sample)
GetSample: Get a sample from the layer. If idx is -1, then get the next round-robbin sample. Otherwise return the indicated sample. Return: The sample and the sample's index.
func (*SampleLayer) NumSamples ¶
func (sl *SampleLayer) NumSamples() int
func (*SampleLayer) Transpose ¶
func (sl *SampleLayer) Transpose(trans int) *SampleLayer
func (*SampleLayer) UpdateCropThresh ¶
func (sl *SampleLayer) UpdateCropThresh(thresh float64)
func (*SampleLayer) UpdateRms ¶
func (sl *SampleLayer) UpdateRms(rmsTime float64)
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
func NewSampler ¶
func (*Sampler) ControllerEvent ¶
func (*Sampler) JackProcess ¶
Jack processing callback.
func (*Sampler) NoteOffEvent ¶
func (*Sampler) NoteOnEvent ¶
---------------------------------------------------------------------------- Functions below protected by mutex.
func (*Sampler) PitchBendEvent ¶
func (*Sampler) UpdateCropThresh ¶
func (s *Sampler) UpdateCropThresh()
---------------------------------------------------------------------------- These functions run slowly and could cause skipping.
type Sound ¶
type Sound struct { Len int // The length of the sound. L []float32 // Left channel. R []float32 // Right channel. }
----------------------------------------------------------------------------
func NewSoundFromSample ¶
type TuningFile ¶
type TuningFile struct {
// contains filtered or unexported fields
}
func LoadTuningFile ¶
func LoadTuningFile() *TuningFile
func (*TuningFile) GetTuning ¶
func (tf *TuningFile) GetTuning(filename string) float64