Documentation
¶
Index ¶
- Constants
- Variables
- func AnglePitch(normal, direction, tangent pt.Vector) float64
- func AngleYaw(normal, direction, tangent, bitangent pt.Vector) float64
- func ComputeMeshVolume(mesh *pt.Mesh) float64
- func EnergyOverWindow(arrivals []Arrival, windowMS float64, floor float64) (float64, error)
- func NewDirectivity(horiz, vert map[float64]float64) *directivity
- func V(X, Y, Z float64) pt.Vector
- type AcousticPathJSON
- type AnalysisResults
- type Annotations
- type Arrival
- type Bounds
- type ListeningTriangle
- func (t ListeningTriangle) Deviation(listenPos pt.Vector) float64
- func (t ListeningTriangle) LeftSourceNormal() pt.Vector
- func (t ListeningTriangle) LeftSourcePosition() pt.Vector
- func (t ListeningTriangle) ListenDistance() float64
- func (t ListeningTriangle) ListenPosition() (ListenPos, EquilateralPos pt.Vector)
- func (t ListeningTriangle) RightSourceNormal() pt.Vector
- func (t ListeningTriangle) RightSourcePosition() pt.Vector
- type LoudSpeakerSpec
- type Material
- type MaterialJSON
- type NearestApproachJSON
- type Path
- type Path2D
- type PathJSON
- type Plane
- type Point
- type Point2D
- type PointJSON
- type PsalmPath
- type RayJSON
- type Reflection
- type ReflectionJSON
- type Room
- func (r *Room) AddPrism(XBound, YBound, ZBound Bounds, name string, material Material) error
- func (r *Room) AddSurface(surface *Surface) error
- func (r *Room) AddWall(point pt.Vector, normal pt.Vector, name string, material Material) error
- func (r *Room) GetSpeakerCone(speaker Speaker, angle float64, N int, color string) ([]PsalmPath, error)
- func (r *Room) InteriorMesh() (*pt.Mesh, error)
- func (r *Room) NominalT60() (float64, error)
- func (r *Room) SchroederFreq() (float64, error)
- func (r *Room) SurfaceArea() (float64, error)
- func (r *Room) T60Eyring(freq float64) (float64, error)
- func (r *Room) T60Sabine(freq float64) (float64, error)
- func (r *Room) TraceShot(shot Shot, listenPos pt.Vector, params TraceParams) ([]Arrival, error)
- func (r *Room) TraceShotUnconditional(shot Shot, listenPos pt.Vector, params TraceParams) ([]Arrival, error)
- func (r *Room) Volume() (float64, error)
- type Scene
- type Shot
- type ShotJSON
- type Size
- type Source
- type Speaker
- func (s Speaker) IsInsideRoom(m *pt.Mesh, listenPos pt.Vector) (offendingVertex pt.Vector, intersectingPoint pt.Vector, ok bool)
- func (s *Speaker) Sample(numSamples int, horizRange, vertRange float64) []Shot
- func (s *Speaker) SampleCone(angleDegrees float64, numRays int) []pt.Ray
- func (s *Speaker) SampleWithNormal(targetVector pt.Vector, numSamples int, horizRange, vertRange float64) []Shot
- type Status
- type Summary
- type Surface
- type SurfaceJSON
- type TraceParams
- type Triangle
- type VectorJSON
- type View
- type Wall
- type Zone
- type ZoneJSON
Constants ¶
const ( // Pastel Colors PastelRed = "#FF6961" PastelOrange = "#FFD1A1" PastelYellow = "#FDFD96" PastelGreen = "#77DD77" PastelBlue = "#AEC6CF" PastelPurple = "#CBAACB" PastelPink = "#FFB7CE" PastelTeal = "#99C5B3" PastelLavender = "#B39EB5" PastelPeach = "#FFDAC1" PastelMint = "#B5EAD7" PastelSky = "#C1E1C1" // Bright Colors BrightRed = "#FF4D4D" BrightOrange = "#FFA64D" BrightYellow = "#FFFF4D" BrightGreen = "#4DFF4D" BrightBlue = "#4D9EFF" BrightPurple = "#B64DB6" BrightPink = "#FF4D93" BrightTeal = "#4DDBC4" BrightLavender = "#C44DFF" BrightPeach = "#FFB84D" BrightMint = "#4DFFD1" BrightSky = "#4DC4FF" )
const ( SABINE = 0.161 EYERING = 55.3 SCHROEDER_COEFF = 2000 )
const INF = 1e9
const LISTEN_DIST_INTO_TRIANGLE = 0.32
Value from Thomas Northward posted on GearSpae
const MS float64 = 1.0 / 1000.0
const SCALE = 1000
const SPEED_OF_SOUND = 343.0
Variables ¶
var NoHit = Arrival{Gain: 0.0, Distance: INF}
Functions ¶
func AnglePitch ¶
Helper: Calculate pitch from speaker normal to direction
func ComputeMeshVolume ¶
ComputeMeshVolume calculates the volume of a closed mesh Note: The mesh must be closed and properly oriented (consistent winding order) Returns: Volume in cubic units of the mesh coordinates
func EnergyOverWindow ¶
func NewDirectivity ¶
Returns a directivity struct, which can compute the gain of a ray shot from a given direction
horiz and vert are maps of angle in degrees to gain in dB. Gain should always be negative except at 0 degrees. Angles must be positive and in ascending order. The gain at angle θ is equal to the gain at angle -θ.
Types ¶
type AcousticPathJSON ¶
type AcousticPathJSON struct {
Reflections []ReflectionJSON `json:"reflections"`
Shot ShotJSON `json:"shot"`
GainFromReflections float64 `json:"gainFromReflections"` // stored in dB
GainFromDistance float64 `json:"gainFromDistance"` // stored in dB
Gain float64 `json:"gain"` // stored in dB
Distance float64 `json:"distance"`
NearestApproach NearestApproachJSON `json:"nearestApproach"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
Thickness float64 `json:"thickness,omitempty"`
}
func ArrivalToAcousticPathJSON ¶
func ArrivalToAcousticPathJSON(a Arrival) AcousticPathJSON
type AnalysisResults ¶
type AnalysisResults struct {
ITD float64 `json:"ITD,omitempty"`
EnergyOverWindow float64 `json:"avg_energy_over_window,omitempty"`
ITD2 float64 `json:"ITD_2,omitempty"`
AvgGain5ms float64 `json:"avg_gain_5ms,omitempty"`
ListenPosX float64 `json:"listen_pos_x,omitempty"`
T60Sabine float64 `json:"T60_sabine,omitempty"`
T60Eyering float64 `json:"T60_eyering,omitempty"`
SchroederFreq float64 `json:"schroeder_freq,omitempty"`
Volume float64 `json:"volume,omitempty"`
NominalT60 float64 `json:"nominal_T60,omitempty"`
}
type Annotations ¶
type Annotations struct {
Points []Point
Paths []PsalmPath
Arrivals []Arrival
Zones []Zone
PathColors map[int]string // This is ugly but yolo
}
func NewAnnotations ¶
func NewAnnotations() *Annotations
func (Annotations) WriteToJSON ¶
func (a Annotations) WriteToJSON(filename string) error
SaveAnnotationsToJson saves points, paths, and both types of paths to a JSON file
type Arrival ¶
type Arrival struct {
// The shot that created this arrival
Shot Shot
// Position of the last reflection
LastReflection pt.Vector
// Slice of positions of all reflections
AllReflections []Reflection
// Gain contribution from imperfect reflection, dB
GainFromReflections float64
// Gain contribution from distance (6dB rule)
GainFromDistance float64
// Gain in dB relative to the direct signal
Gain float64
// Total distance traveled by this ray across all reflections, in meters
Distance float64
// The nearest this arrival came to the listening position
NearestApproachDistance float64
// The position of the nearest aproach
NearestApproachPosition pt.Vector
}
Arrival defines a reflection that arrives within the RFZ
func (Arrival) DirectDist ¶
Returns the distance traveled by the direct signal from source to position of last reflection
type ListeningTriangle ¶
type ListeningTriangle struct {
// A point on the front wall
ReferencePosition pt.Vector
// The normal vector of the front wall
//
// TODO: this is currently ignored. Implement this properly.
ReferenceNormal pt.Vector
// Distance of the sources from the front wall
DistFromFront float64
// Distance of the sources from the horizontal center of the triangle
DistFromCenter float64
// Height of the sources
SourceHeight float64
// Height of the listen position
ListenHeight float64
}
func (ListeningTriangle) Deviation ¶
func (t ListeningTriangle) Deviation(listenPos pt.Vector) float64
func (ListeningTriangle) LeftSourceNormal ¶
func (t ListeningTriangle) LeftSourceNormal() pt.Vector
func (ListeningTriangle) LeftSourcePosition ¶
func (t ListeningTriangle) LeftSourcePosition() pt.Vector
func (ListeningTriangle) ListenDistance ¶
func (t ListeningTriangle) ListenDistance() float64
func (ListeningTriangle) ListenPosition ¶
func (t ListeningTriangle) ListenPosition() (ListenPos, EquilateralPos pt.Vector)
ListenPosition returns two points: the ideal Listening Position within the room and the position of a hypothetical equilateral triangle with the two sources.
The Listening Position is a constant distance into the triangle (TOWARDS the line connecting the two sources), to place the listener's ears directly on the paths from source to the third point of the equilateral triangle ("EquilateralPos").
func (ListeningTriangle) RightSourceNormal ¶
func (t ListeningTriangle) RightSourceNormal() pt.Vector
func (ListeningTriangle) RightSourcePosition ¶
func (t ListeningTriangle) RightSourcePosition() pt.Vector
type LoudSpeakerSpec ¶
type LoudSpeakerSpec struct {
Xdim, Ydim, Zdim float64
Yoff, Zoff float64
HDirectivityMap map[float64]float64
VDirectivityMap map[float64]float64
// contains filtered or unexported fields
}
func (LoudSpeakerSpec) GainDB ¶
func (spec LoudSpeakerSpec) GainDB(yaw, pitch float64) float64
type Material ¶
type Material struct {
// contains filtered or unexported fields
}
func NewMaterial ¶
func PerfectAbsorber ¶
func PerfectAbsorber() Material
func PerfectReflector ¶
func PerfectReflector() Material
type MaterialJSON ¶
func MaterialToJSON ¶
func MaterialToJSON(m Material) MaterialJSON
func (*MaterialJSON) MarshalJSON ¶
func (m *MaterialJSON) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling
type NearestApproachJSON ¶
type PathJSON ¶
type PathJSON struct {
Points []PointJSON `json:"points"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
Thickness float64 `json:"thickness,omitempty"`
}
func PathToJSON ¶
type Plane ¶
func (Plane) IntersectTriangle ¶
type PointJSON ¶
type PointJSON struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
}
func PointToJSON ¶
type RayJSON ¶
type RayJSON struct {
Origin PointJSON `json:"origin"`
Direction VectorJSON `json:"direction"`
}
type Reflection ¶
type ReflectionJSON ¶
type ReflectionJSON struct {
Position PointJSON `json:"position"`
Normal VectorJSON `json:"normal,omitempty"`
Surface SurfaceJSON `json:"surface,omitempty"`
}
func ReflectionToJSON ¶
func ReflectionToJSON(r Reflection) ReflectionJSON
type Room ¶
func NewEmptyRoom ¶
func NewEmptyRoom() Room
func NewFrom3MF ¶
func (*Room) AddSurface ¶
func (*Room) GetSpeakerCone ¶
func (*Room) InteriorMesh ¶
InteriorMesh returns the mesh describing the innermost set of walls in the room
func (*Room) NominalT60 ¶
func (*Room) SchroederFreq ¶
SchroederFreq returns the Schroeder frequency of the room, which is the frequency at which the reverb transitions from modal to specular behavior
func (*Room) SurfaceArea ¶
SurfaceArea returns the surface area of the INTERIOR of the room
func (*Room) TraceShot ¶
TraceShot traces the path taken by a shot until it either arrives at the RFZ or satisfies the othe criteria in params.
See the Params struct type.
func (*Room) TraceShotUnconditional ¶
func (r *Room) TraceShotUnconditional(shot Shot, listenPos pt.Vector, params TraceParams) ([]Arrival, error)
TraceShot traces the path taken by a shot until it either arrives at the RFZ or satisfies the othe criteria in params.
See the Params struct type.
type Scene ¶
type Scene struct {
Sources []Speaker
ListeningPosition pt.Vector
ListeningTriangle ListeningTriangle
Room *Room
}
func (Scene) BoundingBox ¶
type Speaker ¶
type Speaker struct {
LoudSpeakerSpec
Source
}
func NewSpeaker ¶
func (Speaker) IsInsideRoom ¶
func (s Speaker) IsInsideRoom(m *pt.Mesh, listenPos pt.Vector) (offendingVertex pt.Vector, intersectingPoint pt.Vector, ok bool)
IsInsideRoom returns true if the speaker is inside the innermost set of walls of the mesh
func (*Speaker) SampleCone ¶
type Summary ¶
type Summary struct {
Status Status `json:"status"`
Errors []string `json:"errors,omitempty"`
Results AnalysisResults `json:"results"`
}
Summary Results Schema
func NewSummary ¶
func NewSummary() *Summary
func (*Summary) Successful ¶
func (r *Summary) Successful()
func (Summary) WriteToJSON ¶
type SurfaceJSON ¶
type SurfaceJSON struct {
Material MaterialJSON `json:"material"`
Name string `json:"name,omitempty"`
}
func SurfaceToJSON ¶
func SurfaceToJSON(s Surface) SurfaceJSON
type TraceParams ¶
type TraceParams struct {
// Maximum number of reflections to simulate
Order int
// Stop tracing after the reflection loses this many dB relative to the direct signal
GainThreshold float64
// Stop tracing after this many seconds
TimeThreshold float64
// Only reflections that pass within this distance from the listening position will be counted as hits
//
// Distance in meters
RFZRadius float64
}
TraceParams contains parameters to guide tracing
type VectorJSON ¶
JSON schema types