Struct cxx_juce::juce_audio_devices::AudioDeviceManager
source · pub struct AudioDeviceManager { /* private fields */ }Expand description
Manages the state of an audio device.
Implementations§
source§impl AudioDeviceManager
impl AudioDeviceManager
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new AudioDeviceManager.
Examples found in repository?
More examples
examples/devices.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(2, 2)?;
let device_type = audio_device_manager.current_device_type().unwrap();
println!("Inputs:");
for input in device_type.input_devices() {
println!(" {}", input);
}
println!("Outputs:");
for output in device_type.output_devices() {
println!(" {}", output);
}
Ok(())
}examples/test_tone.rs (line 10)
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
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(0, 2)?;
{
let mut device = audio_device_manager.current_device().unwrap();
println!("Name: {}", device.name());
println!("Type: {}", device.type_name());
println!("Sample rate: {}", device.sample_rate());
println!("Buffer size: {}", device.buffer_size());
println!(
"Available sample rates: {:?}",
device.available_sample_rates()
);
println!(
"Available buffer sizes: {:?}",
device.available_buffer_sizes()
);
}
audio_device_manager.play_test_sound();
sleep(Duration::from_secs(1));
Ok(())
}sourcepub fn initialise(
&mut self,
input_channels: usize,
output_channels: usize
) -> Result<()>
pub fn initialise(
&mut self,
input_channels: usize,
output_channels: usize
) -> Result<()>
Resets to a default device setup.
Examples found in repository?
More examples
examples/devices.rs (line 8)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(2, 2)?;
let device_type = audio_device_manager.current_device_type().unwrap();
println!("Inputs:");
for input in device_type.input_devices() {
println!(" {}", input);
}
println!("Outputs:");
for output in device_type.output_devices() {
println!(" {}", output);
}
Ok(())
}examples/test_tone.rs (line 11)
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
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(0, 2)?;
{
let mut device = audio_device_manager.current_device().unwrap();
println!("Name: {}", device.name());
println!("Type: {}", device.type_name());
println!("Sample rate: {}", device.sample_rate());
println!("Buffer size: {}", device.buffer_size());
println!(
"Available sample rates: {:?}",
device.available_sample_rates()
);
println!(
"Available buffer sizes: {:?}",
device.available_buffer_sizes()
);
}
audio_device_manager.play_test_sound();
sleep(Duration::from_secs(1));
Ok(())
}sourcepub fn audio_device_setup(&self) -> AudioDeviceSetup
pub fn audio_device_setup(&self) -> AudioDeviceSetup
Get the current device setup.
sourcepub fn set_audio_device_setup(&mut self, setup: &AudioDeviceSetup)
pub fn set_audio_device_setup(&mut self, setup: &AudioDeviceSetup)
Changes the current device or its settings.
sourcepub fn play_test_sound(&mut self)
pub fn play_test_sound(&mut self)
Play a test sound.
Examples found in repository?
examples/test_tone.rs (line 30)
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
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(0, 2)?;
{
let mut device = audio_device_manager.current_device().unwrap();
println!("Name: {}", device.name());
println!("Type: {}", device.type_name());
println!("Sample rate: {}", device.sample_rate());
println!("Buffer size: {}", device.buffer_size());
println!(
"Available sample rates: {:?}",
device.available_sample_rates()
);
println!(
"Available buffer sizes: {:?}",
device.available_buffer_sizes()
);
}
audio_device_manager.play_test_sound();
sleep(Duration::from_secs(1));
Ok(())
}sourcepub fn device_types(&mut self) -> Vec<impl AudioIODeviceType + '_>
pub fn device_types(&mut self) -> Vec<impl AudioIODeviceType + '_>
Get the available device types.
sourcepub fn current_device_type(&self) -> Option<impl AudioIODeviceType + '_>
pub fn current_device_type(&self) -> Option<impl AudioIODeviceType + '_>
Get the current device type.
Examples found in repository?
examples/devices.rs (line 10)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(2, 2)?;
let device_type = audio_device_manager.current_device_type().unwrap();
println!("Inputs:");
for input in device_type.input_devices() {
println!(" {}", input);
}
println!("Outputs:");
for output in device_type.output_devices() {
println!(" {}", output);
}
Ok(())
}sourcepub fn current_device(&self) -> Option<impl AudioIODevice + '_>
pub fn current_device(&self) -> Option<impl AudioIODevice + '_>
Get the current AudioIODevice.
Examples found in repository?
examples/test_tone.rs (line 14)
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
fn main() -> Result<()> {
let mut audio_device_manager = AudioDeviceManager::new();
audio_device_manager.initialise(0, 2)?;
{
let mut device = audio_device_manager.current_device().unwrap();
println!("Name: {}", device.name());
println!("Type: {}", device.type_name());
println!("Sample rate: {}", device.sample_rate());
println!("Buffer size: {}", device.buffer_size());
println!(
"Available sample rates: {:?}",
device.available_sample_rates()
);
println!(
"Available buffer sizes: {:?}",
device.available_buffer_sizes()
);
}
audio_device_manager.play_test_sound();
sleep(Duration::from_secs(1));
Ok(())
}sourcepub fn add_audio_callback(
&mut self,
callback: impl AudioIODeviceCallback + 'static
) -> AudioCallbackHandle<'_>
pub fn add_audio_callback(
&mut self,
callback: impl AudioIODeviceCallback + 'static
) -> AudioCallbackHandle<'_>
Registers an audio callback.
When the returned AudioCallbackHandle is dropped the callback is removed.
sourcepub fn add_audio_device_type(
&mut self,
device_type: impl AudioIODeviceType + 'static
)
pub fn add_audio_device_type(
&mut self,
device_type: impl AudioIODeviceType + 'static
)
Registers an audio device type.
sourcepub fn set_current_audio_device_type(&mut self, device_type: &str)
pub fn set_current_audio_device_type(&mut self, device_type: &str)
Set the current audio device type to use.