v1

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Male = iota
	Female
	ChildLg
	ChildSm
	Baby
)
View Source
const (
	OroPharynxReg1 = iota // S1
	OroPharynxReg2        // S2
	OroPharynxReg3        // S3
	OroPharynxReg4        // S4 & S5
	OroPharynxReg5        // S6 & S7
	OroPharynxReg6        // S8
	OroPharynxReg7        // S9
	OroPharynxReg8        // S10
	OroPharynxRegCnt
)
View Source
const (
	OroPharynxC1 = iota // R1-R2 (S1-S2)
	OroPharynxC2        // R2-R3 (S2-S3)
	OroPharynxC3        // R3-R4 (S3-S4)
	OroPharynxC4        // R4-R5 (S5-S6)
	OroPharynxC5        // R5-R6 (S7-S8)
	OroPharynxC6        // R6-R7 (S8-S9)
	OroPharynxC7        // R7-R8 (S9-S10)
	OroPharynxC8        // R8-Air (S10-Air)
	OroPharynxCoefCnt
)
View Source
const (
	OroPharynxS1  = iota // OroPharynxReg1
	OroPharynxS2         // OroPharynxReg2
	OroPharynxS3         // OroPharynxReg3
	OroPharynxS4         // OroPharynxReg4
	OroPharynxS5         // OroPharynxReg4
	OroPharynxS6         // OroPharynxReg5
	OroPharynxS7         // OroPharynxReg5
	OroPharynxS8         // OroPharynxReg6
	OroPharynxS9         // OroPharynxReg7
	OroPharynxS10        // OroPharynxReg8
	OroPharynxSectCnt
)
View Source
const (
	NasalS1 = iota
	NasalS2
	NasalS3
	NasalS4
	NasalS5
	NasalS6
	NasalSectCnt
	Velum = NasalS1
)
View Source
const (
	NasalC1      = NasalS1 // N1-N2
	NasalC2      = NasalS2 // N2-N3
	NasalC3      = NasalS3 // N3-N4
	NasalC4      = NasalS4 // N4-N5
	NasalC5      = NasalS5 // N5-N6
	NasalC6      = NasalS6 // N6-Air
	NasalCoefCnt = NasalSectCnt
)
View Source
const (
	ThreeWayLeft = iota
	ThreeWayRight
	ThreeWayUpper
	ThreeWayCnt
)
View Source
const (
	FricationInjC1 = iota // S3
	FricationInjC2        // S4
	FricationInjC3        // S5
	FricationInjC4        // S6
	FricationInjC5        // S7
	FricationInjC6        // S8
	FricationInjC7        // S9
	FricationInjC8        // S10
	FricationInjCoefCnt
)
View Source
const Bottom = 1
View Source
const GlottalSourcePulse = 0
View Source
const GlottalSourceSine = 1
View Source
const GsTrmTubeMinRadius = 0.001
View Source
const OutputScale = 0.95
View Source
const OutputSize = 1024
View Source
const PitchBase = 220.0
View Source
const PitchOffset = 3
View Source
const Top = 0
View Source
const VolMax = 60
View Source
const VtScale = 0.125

Variables

This section is empty.

Functions

func Amplitude

func Amplitude(decibelLevel float64) float64

Amplitude converts dB value to amplitude value

func Frequency

func Frequency(pitch float64) float64

Frequency converts a given pitch (0 = middle C) to the corresponding frequency

func PlaySound

func PlaySound()

func SpeedOfSound

func SpeedOfSound(temp float64) float64

SpeedOfSound returns the speed of sound according to the value of the temperature (in Celsius degrees)

Types

type AgeGender

type AgeGender int32

type FricationInjCoefs

type FricationInjCoefs int32

FricationInjCoefs are the oropharynx scattering junction coefficients (between each region)

type NasalCoefs

type NasalCoefs int32

NasalCoefs

type NasalSections

type NasalSections int32

NasalSections are different sections of the nasal tract

type OroPharynxCoefs

type OroPharynxCoefs int32

OroPharynxCoefs are the oropharynx scattering junction coefficients (between each region)

type OroPharynxRegions

type OroPharynxRegions int32

OroPharynxRegions are different regions of the vocal tract

type OroPharynxSects

type OroPharynxSects int32

OroPharynxCoefs are the oropharynx scattering junction coefficients (between each region)

type ThreeWayJunction

type ThreeWayJunction int32

ThreeWayJunction for the three-way junction alpha coefficients

type TractCtrl

type TractCtrl struct {
	GlotPitch float64    `` /* 137-byte string literal not displayed */
	GlotVol   float64    `min:"0" max:"60" desc:"glottal volume (DB?) typically 60 when present and 0 when not, and sometimes 54, 43.5, 42, "`
	AspVol    float64    `min:"0" max:"10" desc:"aspiration volume -- typically 0 when not present and 10 when present"`
	FricVol   float64    `min:"0" max:"24" desc:"fricative volume -- typically 0 or .25 .4, .5, .8 but 24 for ph"`
	FricPos   float64    `min:"1" max:"7" desc:"ficative position -- varies continuously between 1-7"`
	FricCf    float64    `` /* 136-byte string literal not displayed */
	FricBw    float64    `min:"500" max:"4500" desc:"fricative bw seems like a frequency -- common intermediate values are 600, 900, 2000, 2600"`
	Radii     [7]float64 `desc:"Radii 2-8 radius of pharynx vocal tract segment as determined by tongue etc -- typically around 1, ranging .5 - 1.7"`
	Velum     float64    `min:".1" max:"1.5" desc:"velum opening -- 1.5 when fully open, .1 when closed, and .25, .5 intermediates used"`
}

ToDo: desc for all Radii

func (*TractCtrl) ComputeDeltas

func (vtc *TractCtrl) ComputeDeltas(cur, prv *TractCtrl, cf float64)

ComputeDeltas computes values in this set of params as deltas from (cur - prv) * ctrl_freq

func (*TractCtrl) DefaultMaxDeltas

func (vtc *TractCtrl) DefaultMaxDeltas()

DefaultMaxDeltas updates the default max delta values in this object (for DeltaMax field in VocalTract)

func (*TractCtrl) Defaults

func (vtc *TractCtrl) Defaults()

func (*TractCtrl) RadiusVal

func (vtc *TractCtrl) RadiusVal(idx int) float64

func (*TractCtrl) SetFromParams

func (vtc *TractCtrl) SetFromParams(src *TractCtrl)

SetFromParams fast copy of parameters from other control params

func (*TractCtrl) SetFromValues

func (vtc *TractCtrl) SetFromValues(values []float64)

SetFromValues - order must be preserved!

func (*TractCtrl) UpdateFromDeltas

func (vtc *TractCtrl) UpdateFromDeltas(deltas *TractCtrl)

UpdateFromDeltas updates values in this set of params from deltas

type TractParams

type TractParams struct {
	Temp         float64
	Loss         float64
	MouthCoef    float64
	NoseCoef     float64
	ThroatCutoff float64
	ThroatVol    float64
	VtlOff       float64
	MixOff       float64
	WaveForm     int32
	NoiseMod     bool
}

func (*TractParams) Defaults

func (vtc *TractParams) Defaults()

Defaults sets the default values for the vocal tract

type VocalTract

type VocalTract struct {
	Buf        sound.Wave   `desc:""`
	Volume     float64      `desc:""`
	Balance    float64      `desc:""`
	Duration   float64      `desc:""` // duration of synthesized sound
	Params     TractParams  `desc:""`
	Voice      VoiceParams  `desc:""`
	CurCtrl    TractCtrl    `desc:""`
	PrvCtrl    TractCtrl    `desc:""`
	DeltaCtrl  TractCtrl    `desc:""`
	DeltaMax   TractCtrl    `desc:""`
	PhoneTable etable.Table `desc:""`
	Dictionary etable.Table `desc:""`

	// derived values
	CtrlRate   float64 `desc:""` // 1.0-1000.0 input tables/second (Hz)
	CtrlPeriod int     `desc:""`
	SampleRate int     `desc:""`
	TubeLength float64 `desc:""` // actual length in cm

	CurData TractCtrl `desc:""` // current control data

	// tube and tube coefficients
	Oropharynx      [OroPharynxSectCnt][2][2]float64
	OropharynxCoefs [OroPharynxCoefCnt]float64
	Nasal           [NasalSectCnt][2][2]float64
	NasalCoefs      [NasalCoefCnt]float64
	Alpha           [ThreeWayCnt]float64
	CurPtr          int
	PrvPtr          int

	// memory for frication taps
	FricationTap [FricationInjCoefCnt]float64

	DampingFactor    float64 // calculated
	CrossmixFactor   float64 //  calculated
	BreathFactor     float64
	PrvGlotAmplitude float64

	SynthOutput []float64
	Wave        []float64

	RateConverter         trm.RateConverter
	MouthRadiationFilter  trm.RadiationFilter
	MouthReflectionFilter trm.ReflectionFilter
	NasalRadiationFilter  trm.RadiationFilter
	NasalReflectionFilter trm.ReflectionFilter
	Throat                trm.Throat
	GlottalSource         trm.WavetableGlottalSource
	BandpassFilter        trm.BandpassFilter
	NoiseFilter           trm.NoiseFilter
	NoiseSource           trm.NoiseSource
}

func (*VocalTract) ControlFromTable

func (vt *VocalTract) ControlFromTable(col etensor.Tensor, row int, normalized bool)

func (*VocalTract) Defaults

func (vt *VocalTract) Defaults()

func (*VocalTract) Init

func (vt *VocalTract) Init()

Init gets us going - this is the first function to call

func (*VocalTract) InitNasal

func (vt *VocalTract) InitNasal()

InitNasalCavity

func (*VocalTract) InitSndBuf

func (vt *VocalTract) InitSndBuf(frames int, channels, rate, bitDepth int)

InitBuffer

func (*VocalTract) InitSynth

func (vt *VocalTract) InitSynth()

func (*VocalTract) InitializeSynthesizer

func (vt *VocalTract) InitializeSynthesizer()

InitializeSynthesizer initializes all variables so that the synthesis can be run

func (*VocalTract) LoadDictionary

func (vt *VocalTract) LoadDictionary()

LoadDictionary loads the English dictionary of words composed of phones and transitions

func (*VocalTract) LoadEnglishPhones

func (vt *VocalTract) LoadEnglishPhones()

LoadEnglishPhones loads the file of English phones

func (*VocalTract) MonoScale

func (vt *VocalTract) MonoScale() float64

MonoScale

func (*VocalTract) Reset

func (vt *VocalTract) Reset()

Reset reset all vocal tract values

func (*VocalTract) ResizeSndBuf

func (vt *VocalTract) ResizeSndBuf(frames int)

InitBuffer

func (*VocalTract) SetFricationTaps

func (vt *VocalTract) SetFricationTaps()

SetFricationTaps Sets frication taps according to the current position and amplitude of frication

func (*VocalTract) StereoScale

func (vt *VocalTract) StereoScale(leftScale,
	rightScale *float64)

StereoScale

func (*VocalTract) Synth

func (vt *VocalTract) Synth(reset bool)

Synth set params before making a call to synthesize the signal and then outputs the signal

func (*VocalTract) SynthPhones

func (vt *VocalTract) SynthPhones(phones string, resetFirst, play bool) bool

SynthPhones

func (*VocalTract) SynthReset

func (vt *VocalTract) SynthReset(initBuffer bool)

SynthReset

func (*VocalTract) SynthSignal

func (vt *VocalTract) SynthSignal()

SynthSignal

func (*VocalTract) SynthWord

func (vt *VocalTract) SynthWord(word string, resetFirst bool, play bool) bool

SynthWord

func (*VocalTract) SynthWords

func (vt *VocalTract) SynthWords(ws string, resetFirst bool, play bool) (rval bool, err error)

SynthWords

func (*VocalTract) TubeCoefficients

func (vt *VocalTract) TubeCoefficients()

TubeCoefficients

func (*VocalTract) Update

func (vt *VocalTract) Update(input, frication float64) (output float64)

Update updates the pressure wave throughout the vocal tract, and returns the summed output of the oral and nasal cavities. Also injects frication appropriately

type VoiceParams

type VoiceParams struct {
	TractLength      float64    `desc:"length of vocal tract - shortest for baby voice, longest for male voice"`
	GlotPulseFallMin float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about FallMin/FallMax"`
	GlotPulseFallMax float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about FallMin/FallMax"`
	GlotPitchRef     float64    `desc:"the pitch of the voice is usually set by the frequency of glottal pulses during vowels or voiced consonants"`
	Breath           float64    `desc:"how much air escapes on each glottal pulse, more for female voices"`
	GlotPulseRise    float64    `desc:"glottal pulse is the rate at which the vocal folds of the glottis open and close - not sure about rise"`
	ApertureRadius   float64    `desc:""`
	NoseRadii        [6]float64 `desc:"fixed nose radii (0 - 3 cm)"`
	NoseRadiusCoef   float64    `desc:"global nose radius coefficient"`
	RadiusCoef       float64    `desc:""`
}

VoiceParams are the parameters that control the quality of the voice

func (*VoiceParams) Baby

func (vp *VoiceParams) Baby()

func (*VoiceParams) ChildLg

func (vp *VoiceParams) ChildLg()

func (*VoiceParams) ChildSm

func (vp *VoiceParams) ChildSm()

func (*VoiceParams) Defaults

func (vp *VoiceParams) Defaults()

DefaultParams are the defaults, some of which don't change

func (*VoiceParams) Female

func (vp *VoiceParams) Female()

func (*VoiceParams) Male

func (vp *VoiceParams) Male()

func (*VoiceParams) SetAgeGender

func (vp *VoiceParams) SetAgeGender(voice AgeGender)

SetAgeGender is used to set the voicing parameters to one of several predefined voice param sets

Directories

Path Synopsis
examples
basicsynth command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL