Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ travis.log

# Visual Studio Code
.vscode/.browse.VC.db*
rusty-tags.vi
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ears"
version = "0.8.0"
version = "0.9.0"
authors = ["Jeremy Letang <letang.jeremy@gmail.com>", "Jan Niklas Hasse <jhasse@bixense.com>", "Nick Browne <nickbrowne@users.noreply.github.com>"]
license = "MIT"
keywords = ["audio", "openal", "sndfile", "sound", "music"]
Expand Down
32 changes: 16 additions & 16 deletions src/audio_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ use states::State;
/// The functionnality that an Audio Source should provide.
pub trait AudioController {
/// Play or resume the Audio Source.
fn play(&mut self) -> ();
fn play(&mut self);

/// Pause the Audio Source.
fn pause(&mut self) -> ();
fn pause(&mut self);

/// Stop the Audio Source.
fn stop(&mut self) -> ();
fn stop(&mut self);

/// Connect a ReverbEffect to the Source
fn connect(&mut self, reverb_effect: &Option<ReverbEffect>);
Expand All @@ -62,7 +62,7 @@ pub trait AudioController {
* # Argument
* * `offset` - The frame to seek to
*/
fn set_offset(&mut self, offset: i32) -> ();
fn set_offset(&mut self, offset: i32);

/**
* Get the current position in the Music.
Expand All @@ -82,7 +82,7 @@ pub trait AudioController {
* # Argument
* * `volume` - The volume of the Audio Source, should be between 0.0 and 1.0
*/
fn set_volume(&mut self, volume: f32) -> ();
fn set_volume(&mut self, volume: f32);

/**
* Get the volume of the Audio Source.
Expand All @@ -102,7 +102,7 @@ pub trait AudioController {
* * `min_volume` - The new minimal volume of the Audio Source should be
* between 0.0 and 1.0
*/
fn set_min_volume(&mut self, min_volume: f32) -> ();
fn set_min_volume(&mut self, min_volume: f32);

/**
* Get the minimal volume of the Audio Source.
Expand All @@ -122,7 +122,7 @@ pub trait AudioController {
* * `max_volume` - The new maximal volume of the Audio Source should be
* between 0.0 and 1.0
*/
fn set_max_volume(&mut self, max_volume: f32) -> ();
fn set_max_volume(&mut self, max_volume: f32);

/**
* Get the maximal volume of the Audio Source.
Expand All @@ -140,7 +140,7 @@ pub trait AudioController {
* # Arguments
* `looping` - The new looping state.
*/
fn set_looping(&mut self, looping: bool) -> ();
fn set_looping(&mut self, looping: bool);

/**
* Check if the Audio Source is looping or not
Expand All @@ -161,7 +161,7 @@ pub trait AudioController {
* * `new_pitch` - The new pitch of the Audio Source in the range
* [0.5 - 2.0]
*/
fn set_pitch(&mut self, pitch: f32) -> ();
fn set_pitch(&mut self, pitch: f32);

/**
* Set the pitch of the source.
Expand All @@ -180,7 +180,7 @@ pub trait AudioController {
* `relative` - True to set Audio Source relative to the
* listener false to set the Audio Source position absolute.
*/
fn set_relative(&mut self, relative: bool) -> ();
fn set_relative(&mut self, relative: bool);

/**
* Is the Audio Source relative to the listener or not ?
Expand All @@ -205,7 +205,7 @@ pub trait AudioController {
* * `position` - A three dimensional vector of f32 containing the
* position of the listener [x, y, z].
*/
fn set_position(&mut self, position: [f32; 3]) -> ();
fn set_position(&mut self, position: [f32; 3]);

/**
* Get the position of the Audio Source in three dimensional space.
Expand All @@ -226,7 +226,7 @@ pub trait AudioController {
* # Argument
* `direction` - The new direction of the Audio Source.
*/
fn set_direction(&mut self, direction: [f32; 3]) -> ();
fn set_direction(&mut self, direction: [f32; 3]);

/**
* Get the direction of the Audio Source.
Expand All @@ -248,7 +248,7 @@ pub trait AudioController {
* # Argument
* `max_distance` - The new maximum distance in the range [0.0, +inf]
*/
fn set_max_distance(&mut self, max_distance: f32) -> ();
fn set_max_distance(&mut self, max_distance: f32);

/**
* Get the maximum distance of the Audio Source.
Expand All @@ -270,7 +270,7 @@ pub trait AudioController {
* # Argument
* * `ref_distance` - The new reference distance of the Audio Source.
*/
fn set_reference_distance(&mut self, ref_distance: f32) -> ();
fn set_reference_distance(&mut self, ref_distance: f32);

/**
* Get the reference distance of the Audio Source.
Expand All @@ -292,7 +292,7 @@ pub trait AudioController {
* `attenuation` - The new attenuation for the Audio Source in the
* range [0.0, 1.0].
*/
fn set_attenuation(&mut self, attenuation: f32) -> ();
fn set_attenuation(&mut self, attenuation: f32);

/**
* Get the attenuation of a Sound.
Expand Down Expand Up @@ -325,7 +325,7 @@ pub trait AudioController {
* # Argument
* * `enabled` - true to enable direct channel mode, false to disable
*/
fn set_direct_channel(&mut self, enabled: bool) -> ();
fn set_direct_channel(&mut self, enabled: bool);

/**
* Returns whether direct channel is enabled or not.
Expand Down
22 changes: 12 additions & 10 deletions src/audio_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ pub fn empty() -> Tags {

pub fn get_sound_tags(file: &SndFile) -> Tags {
Tags {
title: file.get_string(Title).unwrap_or("".to_string()),
copyright: file.get_string(Copyright).unwrap_or("".to_string()),
software: file.get_string(Software).unwrap_or("".to_string()),
artist: file.get_string(Artist).unwrap_or("".to_string()),
comment: file.get_string(Comment).unwrap_or("".to_string()),
date: file.get_string(Date).unwrap_or("".to_string()),
album: file.get_string(Album).unwrap_or("".to_string()),
license: file.get_string(License).unwrap_or("".to_string()),
track_number: file.get_string(TrackNumber).unwrap_or("".to_string()),
genre: file.get_string(Genre).unwrap_or("".to_string()),
title: file.get_string(Title).unwrap_or_else(|| "".to_string()),
copyright: file.get_string(Copyright).unwrap_or_else(|| "".to_string()),
software: file.get_string(Software).unwrap_or_else(|| "".to_string()),
artist: file.get_string(Artist).unwrap_or_else(|| "".to_string()),
comment: file.get_string(Comment).unwrap_or_else(|| "".to_string()),
date: file.get_string(Date).unwrap_or_else(|| "".to_string()),
album: file.get_string(Album).unwrap_or_else(|| "".to_string()),
license: file.get_string(License).unwrap_or_else(|| "".to_string()),
track_number: file
.get_string(TrackNumber)
.unwrap_or_else(|| "".to_string()),
genre: file.get_string(Genre).unwrap_or_else(|| "".to_string()),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use record_context::RecordContext;
* ```
*/
pub fn init() -> Result<(), OpenAlContextError> {
return OpenAlData::check_al_context();
OpenAlData::check_al_context()
}

/**
Expand All @@ -64,7 +64,7 @@ pub fn init() -> Result<(), OpenAlContextError> {
* ```
*/
pub fn init_in() -> Result<RecordContext, OpenAlContextError> {
return OpenAlData::check_al_input_context();
OpenAlData::check_al_input_context()
}

#[cfg(test)]
Expand Down
14 changes: 10 additions & 4 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl OpenAlData {
ffi::alcIsExtensionPresent(new_context.al_device, c_str.as_ptr())
} == ffi::ALC_FALSE
{
return Err(OpenAlContextError::NoInputDevice);
Err(OpenAlContextError::NoInputDevice)
} else {
new_context.al_capt_device = unsafe {
ffi::alcCaptureOpenDevice(
Expand All @@ -166,15 +166,15 @@ impl OpenAlData {
)
};
if new_context.al_capt_device == 0 {
return Err(OpenAlContextError::DefaultCaptureDeviceError);
Err(OpenAlContextError::DefaultCaptureDeviceError)
} else {
let cap_device = new_context.al_capt_device;
return Ok(record_context::new(cap_device));
Ok(record_context::new(cap_device))
}
}
}
} else {
return Err(OpenAlContextError::WrongThread);
Err(OpenAlContextError::WrongThread)
}
}
Err(poison_error) => Err(OpenAlContextError::LockError(poison_error.to_string())),
Expand Down Expand Up @@ -232,4 +232,10 @@ macro_rules! check_openal_context(
Err(err) => { println!("{}", err); return $def_ret; }
}
);
() => (
match OpenAlData::check_al_context() {
Ok(_) => {},
Err(err) => println!("{}", err) ,
}
);
);
20 changes: 10 additions & 10 deletions src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ use openal::{al, ffi};
* listener::set_volume(0.7f32);
* ```
*/
pub fn set_volume(volume: f32) -> () {
check_openal_context!(());
pub fn set_volume(volume: f32) {
check_openal_context!();
al::alListenerf(ffi::AL_GAIN, volume);
}

Expand Down Expand Up @@ -86,8 +86,8 @@ pub fn get_volume() -> f32 {
* # use ears::listener;
* listener::set_position([45., 90., 35.]);
*/
pub fn set_position(position: [f32; 3]) -> () {
check_openal_context!(());
pub fn set_position(position: [f32; 3]) {
check_openal_context!();
al::alListenerfv(ffi::AL_POSITION, &position[0]);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn get_position() -> [f32; 3] {
* ```
*/
pub fn set_orientation(orientation_at: [f32; 3], orientation_up: [f32; 3]) {
check_openal_context!(());
check_openal_context!();
let orientation: [f32; 6] = [
orientation_at[0],
orientation_at[1],
Expand Down Expand Up @@ -174,8 +174,8 @@ pub fn get_orientation() -> ([f32; 3], [f32; 3]) {
* * `velocity` - A three dimensional vector of f32 containing the velocity
* of the sound [x, y, z].
*/
pub fn set_velocity(velocity: [f32; 3]) -> () {
check_openal_context!(());
pub fn set_velocity(velocity: [f32; 3]) {
check_openal_context!();

al::alListenerfv(ffi::AL_VELOCITY, &velocity[0]);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ mod test {

#[test]
#[ignore]
pub fn listener_set_volume() -> () {
pub fn listener_set_volume() {
set_volume(0.77);
assert_eq!(get_volume(), 0.77);
}
Expand All @@ -212,15 +212,15 @@ mod test {

#[test]
#[ignore]
pub fn listener_set_position() -> () {
pub fn listener_set_position() {
set_position([50f32, 150f32, 234f32]);
let res = get_position();
assert_eq!((res[0], res[1], res[2]), (50f32, 150f32, 234f32))
}

#[test]
#[ignore]
pub fn listener_set_orientation() -> () {
pub fn listener_set_orientation() {
set_orientation([50., 150., 234.], [277., 125., 71.]);
let (s1, s2) = get_orientation();
assert_eq!(s1, [50f32, 150f32, 234f32]);
Expand Down
Loading