voirs-spatial 0.1.0-rc.1

3D spatial audio and HRTF processing for VoiRS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
//! Core types and enums for telepresence system

use crate::Position3D;
use serde::{Deserialize, Serialize};

/// Noise suppression algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum NoiseSuppressionAlgorithm {
    /// Spectral subtraction
    SpectralSubtraction,

    /// Wiener filtering
    WienerFilter,

    /// Neural network based
    NeuralNetwork,

    /// Minimum mean square error
    MMSE,

    /// Hybrid approach
    Hybrid,
}

/// Echo cancellation algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum EchoCancellationAlgorithm {
    /// Normalized Least Mean Squares
    NLMS,

    /// Recursive Least Squares
    RLS,

    /// Proportionate NLMS
    PNLMS,

    /// Kalman filter based
    Kalman,

    /// Frequency domain adaptive filter
    FrequencyDomain,
}

/// VAD algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum VadAlgorithm {
    /// Energy-based VAD
    Energy,

    /// Spectral-based VAD
    Spectral,

    /// Model-based VAD
    Model,

    /// Neural network VAD
    Neural,

    /// Hybrid VAD
    Hybrid,
}

/// EQ band types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum EqBandType {
    /// Low shelf
    LowShelf,

    /// High shelf
    HighShelf,

    /// Peaking
    Peaking,

    /// Low pass
    LowPass,

    /// High pass
    HighPass,

    /// Notch
    Notch,
}

/// Equalization types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum EqualizationType {
    /// Parametric EQ
    Parametric,

    /// Graphic EQ
    Graphic,

    /// Shelving EQ
    Shelving,

    /// Custom filter
    Custom,
}

/// Bandwidth extension algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum BandwidthExtensionAlgorithm {
    /// Spectral replication
    SpectralReplication,

    /// Harmonic extension
    HarmonicExtension,

    /// Neural network extension
    NeuralExtension,

    /// Model-based extension
    ModelBased,
}

/// Noise color types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum NoiseColor {
    /// White noise
    White,

    /// Pink noise
    Pink,

    /// Brown noise
    Brown,

    /// Blue noise
    Blue,

    /// Custom spectrum
    Custom,
}

/// HRTF personalization methods
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PersonalizationMethod {
    /// Anthropometric scaling
    Anthropometric,

    /// Machine learning adaptation
    MachineLearning,

    /// User feedback adaptation
    UserFeedback,

    /// Hybrid approach
    Hybrid,
}

/// Room shape types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum RoomShape {
    /// Rectangular room
    Rectangular,

    /// L-shaped room
    LShaped,

    /// Circular room
    Circular,

    /// Irregular shape
    Irregular,

    /// Custom shape
    Custom,
}

/// Opening types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum OpeningType {
    /// Door
    Door,

    /// Window
    Window,

    /// Archway
    Archway,

    /// Vent
    Vent,

    /// Custom opening
    Custom,
}

/// Furniture types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum FurnitureType {
    /// Table
    Table,

    /// Chair
    Chair,

    /// Sofa
    Sofa,

    /// Bookshelf
    Bookshelf,

    /// Desk
    Desk,

    /// Bed
    Bed,

    /// Custom furniture
    Custom,
}

/// Movement types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum MovementType {
    /// Free movement
    Free,

    /// Walking only
    Walking,

    /// Seated position
    Seated,

    /// Standing only
    Standing,

    /// Teleport movement
    Teleport,
}

/// Acoustic matching algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AcousticMatchingAlgorithm {
    /// Direct parameter matching
    Direct,

    /// Convolution-based matching
    Convolution,

    /// ML-based matching
    MachineLearning,

    /// Hybrid matching
    Hybrid,
}

/// Shared space types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SharedSpaceType {
    /// Virtual lobby
    Lobby,

    /// Meeting room
    MeetingRoom,

    /// Breakout room
    BreakoutRoom,

    /// Social space
    SocialSpace,

    /// Custom space
    Custom,
}

/// Attenuation models
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AttenuationModel {
    /// Inverse distance law
    InverseDistance,

    /// Inverse square law
    InverseSquare,

    /// Linear attenuation
    Linear,

    /// Exponential attenuation
    Exponential,

    /// Custom model
    Custom,
}

/// Quality levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum QualityLevel {
    /// Low quality (optimized for bandwidth)
    Low,

    /// Medium quality (balanced)
    Medium,

    /// High quality (optimized for quality)
    High,

    /// Ultra quality (maximum quality)
    Ultra,

    /// Custom quality settings
    Custom,
}

/// Latency priority levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LatencyPriority {
    /// Minimize latency
    Low,

    /// Balance latency and quality
    Medium,

    /// Accept higher latency for quality
    High,
}

/// Audio codecs
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AudioCodec {
    /// Opus codec
    Opus,

    /// AAC codec
    AAC,

    /// MP3 codec
    MP3,

    /// PCM (uncompressed)
    PCM,

    /// G.722 codec
    G722,

    /// G.711 codec
    G711,

    /// Custom codec
    Custom(String),
}

/// Codec fallback behavior
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CodecFallbackBehavior {
    /// Use next preferred codec
    NextPreferred,

    /// Use most compatible codec
    MostCompatible,

    /// Use lowest latency codec
    LowestLatency,

    /// Fail if preferred not available
    Fail,
}

/// Spatial quality levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SpatialQualityLevel {
    /// Basic stereo positioning
    Basic,

    /// Enhanced spatial processing
    Enhanced,

    /// Full 3D spatial audio
    Full3D,

    /// Ultra-high fidelity spatial
    UltraHiFi,
}

/// Head tracking sources
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum TrackingSource {
    /// VR headset tracking
    VRHeadset,

    /// Webcam-based tracking
    Webcam,

    /// IMU-based tracking
    IMU,

    /// Phone/tablet gyroscope
    MobileGyroscope,

    /// External tracking system
    External,

    /// No tracking (static)
    None,
}

/// Prediction algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PredictionAlgorithm {
    /// Linear extrapolation
    Linear,

    /// Kalman filter
    Kalman,

    /// Neural network
    Neural,

    /// Adaptive filter
    Adaptive,
}

/// Indicator styles
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum IndicatorStyle {
    /// Minimal indicators
    Minimal,

    /// Standard indicators
    Standard,

    /// Rich indicators
    Rich,

    /// Custom style
    Custom,
}

/// Connection types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ConnectionType {
    /// Direct peer-to-peer
    P2P,

    /// Server-mediated
    ServerMediated,

    /// TURN relay
    TurnRelay,

    /// STUN-assisted
    StunAssisted,

    /// Automatic selection
    Auto,
}

/// DSCP marking for QoS
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum DscpMarking {
    /// Best effort
    BestEffort,

    /// Expedited forwarding
    ExpeditedForwarding,

    /// Assured forwarding
    AssuredForwarding,

    /// Voice
    Voice,

    /// Custom DSCP value
    Custom(u8),
}

/// Congestion control algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CongestionControlAlgorithm {
    /// TCP-friendly
    TcpFriendly,

    /// Google Congestion Control
    GCC,

    /// WebRTC congestion control
    WebRTC,

    /// Custom algorithm
    Custom,
}

/// STUN protocols
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum StunProtocol {
    /// UDP
    UDP,

    /// TCP
    TCP,

    /// TLS
    TLS,
}

/// TURN protocols
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum TurnProtocol {
    /// UDP
    UDP,

    /// TCP
    TCP,

    /// TLS
    TLS,

    /// DTLS
    DTLS,
}

/// ICE gathering policies
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum IceGatheringPolicy {
    /// Gather all candidates
    All,

    /// Only relay candidates
    Relay,

    /// No host candidates
    NoHost,
}

/// ICE transport policies
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum IceTransportPolicy {
    /// All transports
    All,

    /// Only relay
    Relay,

    /// No UDP
    NoUDP,
}

/// Redundancy types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum RedundancyType {
    /// Active-passive
    ActivePassive,

    /// Active-active
    ActiveActive,

    /// Load balancing
    LoadBalancing,

    /// Path diversity
    PathDiversity,
}

/// Channel configurations
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ChannelConfiguration {
    /// Mono
    Mono,

    /// Stereo
    Stereo,

    /// Binaural
    Binaural,

    /// Multi-channel
    MultiChannel(u8),
}

/// HRTF quality levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HrtfQualityLevel {
    /// Basic HRTF
    Basic,

    /// Standard HRTF
    Standard,

    /// High-quality HRTF
    High,

    /// Ultra HRTF
    Ultra,
}

/// Room quality levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum RoomQualityLevel {
    /// Simple room model
    Simple,

    /// Standard room model
    Standard,

    /// Advanced room model
    Advanced,

    /// Ultra-realistic room model
    UltraRealistic,
}

/// Distance precision levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum DistancePrecisionLevel {
    /// Low precision
    Low,

    /// Medium precision
    Medium,

    /// High precision
    High,

    /// Ultra precision
    Ultra,
}

/// Quality adaptation algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum QualityAdaptationAlgorithm {
    /// Bandwidth-based adaptation
    BandwidthBased,

    /// Latency-based adaptation
    LatencyBased,

    /// Machine learning adaptation
    MachineLearning,

    /// Hybrid adaptation
    Hybrid,
}

/// Adaptation speeds
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AdaptationSpeed {
    /// Slow adaptation
    Slow,

    /// Medium adaptation
    Medium,

    /// Fast adaptation
    Fast,

    /// Instant adaptation
    Instant,
}

/// Performance metrics
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PerformanceMetric {
    /// Audio latency
    AudioLatency,

    /// Processing latency
    ProcessingLatency,

    /// Network latency
    NetworkLatency,

    /// Packet loss
    PacketLoss,

    /// Jitter
    Jitter,

    /// CPU usage
    CpuUsage,

    /// Memory usage
    MemoryUsage,

    /// Audio quality score
    AudioQuality,

    /// Spatial accuracy
    SpatialAccuracy,
}

/// Anonymization methods
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AnonymizationMethod {
    /// Voice conversion
    VoiceConversion,

    /// Pitch shifting
    PitchShifting,

    /// Spectral masking
    SpectralMasking,

    /// Statistical anonymization
    Statistical,
}

/// Anonymization strengths
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AnonymizationStrength {
    /// Light anonymization
    Light,

    /// Medium anonymization
    Medium,

    /// Strong anonymization
    Strong,

    /// Maximum anonymization
    Maximum,
}

/// Consent withdrawal mechanisms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ConsentWithdrawalMechanism {
    /// Immediate withdrawal
    Immediate,

    /// End of session withdrawal
    EndOfSession,

    /// Manual request
    ManualRequest,

    /// Automatic expiry
    AutomaticExpiry,
}

/// User state in session
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserState {
    /// Active and speaking
    Active,

    /// Connected but muted
    Muted,

    /// Away from keyboard
    Away,

    /// Busy/do not disturb
    Busy,

    /// Disconnected
    Disconnected,
}

/// Session status
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SessionStatus {
    /// Initializing
    Initializing,

    /// Active
    Active,

    /// Paused
    Paused,

    /// Reconnecting
    Reconnecting,

    /// Terminated
    Terminated,

    /// Error state
    Error,
}

/// Audio processing status
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ProcessingStatus {
    /// Raw received data
    Raw,

    /// Decoded but not processed
    Decoded,

    /// Spatially processed
    SpatiallyProcessed,

    /// Ready for playback
    ReadyForPlayback,

    /// Processing error
    Error,
}

/// Encryption algorithms
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum EncryptionAlgorithm {
    /// AES-256
    AES256,

    /// ChaCha20-Poly1305
    ChaCha20Poly1305,

    /// DTLS-SRTP
    DTLSSRTP,

    /// Custom algorithm
    Custom,
}

/// Key exchange methods
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum KeyExchangeMethod {
    /// Diffie-Hellman
    DiffieHellman,

    /// ECDH
    ECDH,

    /// RSA
    RSA,

    /// Pre-shared key
    PreSharedKey,
}

/// Authentication methods
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AuthenticationMethod {
    /// Username/password
    UsernamePassword,

    /// Token-based
    Token,

    /// Certificate-based
    Certificate,

    /// OAuth
    OAuth,

    /// SAML
    SAML,
}

/// Access control modes
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AccessControlMode {
    /// Allow all (default)
    AllowAll,

    /// Whitelist only
    Whitelist,

    /// Blacklist
    Blacklist,

    /// Geographic restrictions
    Geographic,
}

/// Session privacy levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SessionPrivacy {
    /// Public session
    Public,

    /// Private session (invite only)
    Private,

    /// Password protected
    PasswordProtected,

    /// Authenticated users only
    AuthenticatedOnly,
}

/// 3D orientation representation
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Orientation {
    /// Yaw (rotation around Y axis, degrees)
    pub yaw: f32,

    /// Pitch (rotation around X axis, degrees)
    pub pitch: f32,

    /// Roll (rotation around Z axis, degrees)
    pub roll: f32,
}

/// Velocity vector
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Velocity {
    /// X component (m/s)
    pub x: f32,

    /// Y component (m/s)
    pub y: f32,

    /// Z component (m/s)
    pub z: f32,
}

/// Bounding box for movement
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct BoundingBox {
    /// Minimum corner
    pub min: Position3D,

    /// Maximum corner
    pub max: Position3D,
}

/// Movement constraints for users
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MovementConstraints {
    /// Allowed area bounds
    pub bounds: Option<BoundingBox>,

    /// Movement speed limit (m/s)
    pub max_speed: f32,

    /// Allowed movement types
    pub allowed_movements: Vec<MovementType>,
}