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
/*
    Copyright (C) 2020-2022  Rafal Michalski

    This file is part of SPECTRUSTY, a Rust library for building emulators.

    For the full copyright notice, see the lib.rs file.
*/
/*! # Audio API.
```text
                     /---- ensure_audio_frame_time ----\
  +----------------------+                         +--------+
  |    UlaAudioFrame:    |  render_*_audio_frame   |        |
  |      AudioFrame +    | ======================> |  Blep  |
  | EarMicOutAudioFrame +|     end_audio_frame     |        |
  |   EarInAudioFrame +  |                         |        |
  |   [ AyAudioFrame ]   |                         +--------+
  +----------------------+                             |     
  |      AmpLevels       |        /----------------- (sum)   
  +----------------------+        |                    v       
                                  v                 carousel 
                           +-------------+   +--------------------+
                           | (WavWriter) |   | AudioFrameProducer |
                           +-------------+   +--------------------+
                                               || (AudioBuffer) ||
                                             +====================+
                                             |  * audio thread *  |
                                             |                    |
                                             | AudioFrameConsumer |
                                             +====================+
```
*/
pub use spectrusty_core::audio::*;
#[cfg(feature = "peripherals")] use crate::peripherals::ay::audio::AyAudioFrame;

// This is an arbitrary value for Blep implementation to reserve memory for additional samples.
// This is twice the value of the maximum number of wait-states added by an I/O device.
pub const MARGIN_TSTATES: FTs = 2800;

#[cfg(feature = "audio")]
pub use spectrusty_audio::*;

/// A grouping trait of common audio rendering traits for all emulated `Ula` chipsets.
#[cfg(feature = "peripherals")] pub trait UlaAudioFrame<B: Blep>: AudioFrame<B> +
                                  EarMicOutAudioFrame<B> +
                                  EarInAudioFrame<B> +
                                  AyAudioFrame<B> {}

#[cfg(not(feature = "peripherals"))] pub trait UlaAudioFrame<B: Blep>: AudioFrame<B> +
                                  EarMicOutAudioFrame<B> +
                                  EarInAudioFrame<B> {}

#[cfg(feature = "peripherals")]
impl<B: Blep, U> UlaAudioFrame<B> for U
    where U: AudioFrame<B> + EarMicOutAudioFrame<B> + EarInAudioFrame<B> + AyAudioFrame<B>
{}

#[cfg(not(feature = "peripherals"))]
impl<B: Blep, U> UlaAudioFrame<B> for U
    where U: AudioFrame<B> + EarMicOutAudioFrame<B> + EarInAudioFrame<B>
{}