-
Notifications
You must be signed in to change notification settings - Fork 262
Feature: ChannelRouter #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iluvcapra
wants to merge
32
commits into
RustAudio:master
Choose a base branch
from
iluvcapra:feature-channelrouter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
f497703
Adding a ChannelRouter source
iluvcapra cfdea36
Implementation continues
iluvcapra 121105e
Simplified handling of frame endings
iluvcapra edc683b
More implementation, added mod functions
iluvcapra 6037f67
Some documentation
iluvcapra b45b936
Flatted-out next a little
iluvcapra 51b1f4b
rusfmt and typo
iluvcapra 67b16a1
Typos and added methods, also documentation
iluvcapra f7d8220
clippy
iluvcapra 1204fdf
Inline everything!
iluvcapra 9d43421
Added extract_channels and extract_channel sources
iluvcapra 77763ae
Gains implemented as an atomic array of f32s
iluvcapra 3f16c25
Mutex-implemented, but need to clean this up
iluvcapra d39bbf2
Implemented updates with a mpsc::channel
iluvcapra 45c4688
rustfmt
iluvcapra 1662db2
Added more router conveniences
iluvcapra 9b361b0
Added some comments and stubbed-out tests
iluvcapra 5621477
Added some static tests
iluvcapra ca2ee9d
Added description to changelog
iluvcapra f521000
Test of the controller
iluvcapra 9ae7119
rustfmt
iluvcapra 0fe726c
Docstring for CI
iluvcapra 08789de
For the pickier ubuntu-latest clippy
iluvcapra 8cc8c6e
Removing the todo and addressing clippy
iluvcapra 084fb78
Additional tests and impl for tests
iluvcapra c9cc895
Update channel_router.rs
iluvcapra a6f0873
Added a channel_routing example
iluvcapra cd51ea9
Merge branch 'feature-channelrouter' of https://github.com/iluvcapra/…
iluvcapra d0bdd45
Made channel_routing example interactive
iluvcapra 276f23f
rustfmt
iluvcapra 57b3fd3
Merge branch 'master' of https://github.com/RustAudio/rodio into feat…
iluvcapra 5ed8da2
Test fixes
iluvcapra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! Channel router example | ||
|
||
use std::error::Error; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
use rodio::source::{Function, SignalGenerator, Source}; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
let stream_handle = rodio::OutputStreamBuilder::open_default_stream()?; | ||
|
||
// let test_signal_duration = Duration::from_millis(1000); | ||
let interval_duration = Duration::from_millis(100); | ||
let sample_rate = cpal::SampleRate(48000); | ||
|
||
let (mut controller, router) = SignalGenerator::new(sample_rate, 1000.0, Function::Triangle) | ||
.amplify(0.1) | ||
.channel_router(2, vec![vec![0.0f32, 0.0f32]]); | ||
|
||
println!("Playing 1000Hz tone"); | ||
|
||
stream_handle.mixer().add(router); | ||
|
||
for i in 0..1000 { | ||
thread::sleep(interval_duration); | ||
let n = i % 20; | ||
match n { | ||
0 => println!("Left speaker ramp up"), | ||
1..10 => { | ||
_ = controller.map(0, 0, n as f32 / 10.0); | ||
_ = controller.map(0, 1, 0f32); | ||
} | ||
10 => println!("Right speaker ramp up"), | ||
11..20 => { | ||
_ = controller.map(0, 0, 0.0f32); | ||
_ = controller.map(0, 1, (n - 10) as f32 / 10.0); | ||
} | ||
_ => {} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not very readable right? I can guess its channel from, channel too, gain? But we might be able to do better. I see a number of options, there might well be more:
1️⃣ make map take a struct like:
controller.map(Mapping { from: 0, to: 1, gain: 0f32 })
2️⃣ make map a builder:
controller.map().from(0).to(1).with_gain(0.f32).appy()
. Here you could make the gain optional and do a default of 1.03️⃣ rename it so the argument names are in the name:
controller.map_from_to_with_gain(0, 1, 0f32)
.I think 2️⃣ is my favorite, though its a little more code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the builder too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of builder
.from(0).to(1).with_gain(0.f32)
should always go together at least it should be single call with 3 parameters.I'd prefer a shorter name than
controller.map_from_to_with_gain(0, 1, 0f32)
since it is the only function supported by the router. maybe evencontroller.link(0, 1, 0f32)
what it links can be figured out from the parameter names: