rodio | Rust audio playback library | Audio Utils library
kandi X-RAY | rodio Summary
kandi X-RAY | rodio Summary
Rust audio playback library
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rodio
rodio Key Features
rodio Examples and Code Snippets
Community Discussions
Trending Discussions on rodio
QUESTION
I have done a small program, and it shows a weird behavior that I cannot explain. I am using rodio crate to try out some audio stuff.
I have done two programs that, in my opinion, should give the same result.
The first one I use matches to handle errors:
...ANSWER
Answered 2021-Sep-30 at 19:08The issue is one of scoping and an implementation detail of rodio: the one critical item here is OutputStream::try_default()
, it doesn't really matter how you handle Sink::try_new(&handle)
it'll always behave the same, not so try_default
, if you match or if let
it it'll work fine, if you unwrap
it it'll fail.
But why would that be, the two should be equivalent. The answer is in the details of rodio, specifically of OutputStreamHandle
:
QUESTION
I'm new to the rust and I've been playing around with the Rodio audio library. I can play an audio file on the default audio output device like this:
...ANSWER
Answered 2022-Mar-14 at 15:17rodio
uses cpal
as the underlying audio library. This is where the concepts of host and device come from. Use the re-exported cpal
module from rodio
to get the system host and obtain a list of output devices.
QUESTION
i have select on my page that allows me to dynamically create rodio groups. When I change select options I remove old radios and append new ones to the same form. Now I need to read the value of the selected radio from the given group that is currently 'visible'. Radio groups have unique names. When I try execute a function with the code below i get Uncaught TypeError: document.querySelector(...) is null. What I'm trying to get with these loops is to find the right radios group and get value (most important) from the selected one. If there is a simpler or diffrent way of doing this i'm open to good word, preferably in js. This is what i have at this point of time
...ANSWER
Answered 2021-Aug-02 at 20:27Working code, i used element.querySelector, where let parent is parent element to my radio buttons.
QUESTION
I am trying to take input from the user in the form of a String and passing it as a path for Rodio to play the audio file. When I pass it a hard-coded path it seems to work just fine but when I type the same path in as input it will give me an error.
code:
...ANSWER
Answered 2021-Jun-24 at 00:28When you read a line from stdin, it typically comes with the new line included at the end (from when you pressed the enter key).
If you print out the strings using the debug format specifier, i.e. println!("{:?}", &path);, it will show any escape sequences in the string you could not otherwise see.
You may need to use str::trim or a similar method to remove the newline. – Cormac O'Brien
QUESTION
I'm using glutin
and so have a move closure for my program's main loop and I'm trying to play an audio file with the rodio
crate. With the following code everything works and I get one beep every time the program loops:
ANSWER
Answered 2021-Jun-15 at 16:27Basically, the problem at hand is that rodio::Decoder::new
consumes the value which it reads from (well, actually it is already consumed by BufReader::new
). So, if you have a loop or a closure that can be called multiple times, you have to come up with a fresh value each time. This what File::open
does in your first code snipped.
In your second code snipped, you only create a File
once, and then try to consume it multiple times, which Rust's ownership concept prevents you from doing.
Also notice, that using reference is sadly not really an option with rodio
since the decoders must be 'static
(see for instance the Sink::append
trait bound on S
).
If you think your file system is a bit slow, and you want to optimize this, then you might actually want to read the entire file up-front (which File::open
doesn't do). Doing this should also provide you with a buffer (e.g. a Vec
) that you can clone, and thus allows to repeatedly create fresh values that can be consumed by the Decoder
. Here is an example doing this:
QUESTION
I'm trying to play some audio on my Pi, but I have reached a dead end with the borrowed value does not live long enough
, which does not make sense to me, because I create the variables in main
and afterwards enter an endless loop. Shouldn't welcome
& goodbye
live main
throughout the program execution?
Full error:
...ANSWER
Answered 2021-Mar-17 at 17:47As far as I can tell from rodio docs, the issue is that play_raw()
sends the stream to a dedicated thread, so you can't send it a reference to a local variable - as far as Rust knows, the thread could outlive the local object. In Rust parlance, play_raw
requires a Send + 'static
source.
The other issue is that you cannot have multiple decoders reading the same File
. Although it may seem ok for multiple handles to "read" from the same source, it's actually not because File
is stateful, it contains a pointer to how much of the file has been read. This is why methods like File::read
take &mut self
.
The solution is to open the file in each loop iteration. For example (untested):
QUESTION
I have used rodio crate for playing audio from local file, by going through docs, but not able to figure out how to play audio using url.
...ANSWER
Answered 2020-Aug-18 at 10:12Here is a simple example using blocking reqwest. This downloads the entire audio file into memory before it starts playing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rodio
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page