Asked
— Edited
Hi all,
Has anyone been able to Stream audio triggered from other programs through ARC over wifi to an EZB? I know the PC soundboard will play sound files located on your laptop. But what I want to do is play audio on an EZB that would normally play through my PC's speaker. For example maybe an internet radio show, a youtube video audio track, sound files triggered and used by another program on the laptop other then ARC.
Thanks in advance.
Related Hardware EZ-B v4
When you capture sound or video, there is a delay until you fill a buffer, and then you start doing something at specific intervals.
Buffering introduces a delay between the real data (sound) and whatever you do next with the captured data (play on the EZB).
The capture process introduces a buffer of 5 seconds, this means when a capture action is received, 5 seconds are captured and only then are ready to be forward to a device, and then repeating a cycle of 5 seconds
It could be less time.
why is needed a buffer ? all the code running between capture, re-sampling, sending to EZB, takes cpu time.
When capturing sound the encoding will vary per device, generally the output device (Speakers) generates: Stereo, 48Khz, 32 Bits
EZB accepts Mono, 14.7Khz, 8 Bits.
The re-sampling is also done by the capture action.
As an example:
1 second of sound captured represents: 48000 x 4 (32bits) x 2 (Stereo) = 384K
1 second of sound sent to EZB represents: 14700 x 1 (8bit) x 1 (Mono) = 14.7 K
Each capture action, is a different thread and is responsible for capturing, resample, record to file (if specified), and forward to all EZBs listening.
The capture thread forwards the sound at specific intervals (5 seconds).
BUT if you do this:
Code:
EZB 1 will have a delay of a 1 second or more compared to EZB 0
If you want 1 or more EZBs synchronized you should add them to the same capture.
Sorry the "mambo jambo" stuff, but sometimes it's necessary to explain the implementation details.
As great as this works I was wondering if you had a couple ideas. You mentioned that the buffering delay could be shortened. How would I do that and how short could we go? Also is there any way to stop the speakers on the computer from playing when streaming to EZB when using this plugin? It would be nice to have the only sound coming from the EZB like hen you use the V4 Soundboard. ? Perhaps I could install another audio device? I did notice that if I raise or lower the volume or even mute it on the computer the EZB speaker will adjust at the same time.
If non of that is possible then as it is, this plugin you made is fabulous anyway.
I ll need to investigate.
i have some other projects on queue (Kinect is one of them), i ll come back to this as soon as possible.
but i'm always open to brainstorm ideas.
One question before you mention you capture sounds from an APP to stream to EZB, what kind of app is that ?
Anyway, there's no big hurry. What you have done so far is amazing and much appreciated. Take care of your other projects. They sound awesome also. In the meantime I have lot of other things to do including play with this new plugin of yours.
Here is an example:
https://www.amazon.com/Sabrent-External-Adapter-Windows-AU-MMSA/dp/B00IRVQ0F8?ie=UTF8&ref_=zg_bs_3015427011_1
If the app you are using to play sounds doesn't allow selection of the sound device, the Windows 10 Mixer does allow you to specify which device is used for which applications.
It would probably be possible to create a "dummy" sound driver that did the same without hardware, but I doubt it exists today since the use cases are pretty small and there is no way you could get someone to write one for less than the hardware solution costs.
Alan
Good info,
the first time i played with windows sound api, i used DirectSound, the plugin has some direct sound api code, but, is not being used.
A funny fact, i'm using code from 1999, so still working today
With Direct Sound you need to rely on the hardware board to provide a Mix or loopback device.
If not available the solution would be to wire the speakers output to a line IN to capture sound.
but the game changed, when Vista was launched, a new API WASAPI the "Loopback" channel is done by the new API, so does not matter what kind of hardware driver.
I believe the wasapi loopback is like a Y cable, so you are dependent of the speakers volume, you don't have control over the output. I noticed that with the sound format, you can't instruct the API to capture the sound with a specific format.
Alan suggestion makes sense, although i think it's possible to create a software Endpoint, but it can't be hosted inside an ARC skill plugin.
@Dave, what kind of Windows you have ?
This should work just fine. I plugged in a set of head phones into the laptop jack just so I couldn't hear the first stanza from the computer speaker before the 5 second buffering delay out of the EZB. Other then faintly hearing the Munchkin like voice out of the head phones it took care of the problem.
As for the 5 second delay; Did I mention I'm using Speech Recognition to trigger Scripts that run the Remote Mouse plugin so I can click on a phrase in an outside program to say the time and/or date in the robot's orignal Lost in Space TV voice? I'm using the I-B9 voice interaction program available through the B9 Robot Builders Club here:
Craig Reinbrecht's I-B9 program
I have that scripted now but there is that 5 second delay between when I ask for the time and date answers and the responce. What I've doe to deal with that is to place a command in the script to have the V4 Soundboard play a voice file or two while I wait; "Please Stand By", "Checking". and things like that.
Well, that's my setup so far. I only have hit one issue; often while this above process is happening the EZB will disconnect from ARC and the robot will lockup, turn on a lot of his motors and lights triggered from controls attached to EZB's Digital Ports. Also (and more annoying) the sound file will keep repeating a few words of the file like "Please Stand, Please Stand, Please Stand, Please Stand". Well you get the picture. I'll be troubleshooting this issue today hopefully. I'm pretty sure it's not a low power or WIFI signal strength issue. I have lots of other load on the system at other times with no issues and the WiFi signal strength is very strong.
I'll be looking at the script and what is being done at the time of disconnect. Really only a few things are happening;
*The Audio Toolbox is turned on.
*The V4 Soundboard runs a sound file or two and then stops.
*The Remote Mouse plugin clicks on the I-B9 software icon on the Windows toolbar to switch over to that program and clicks on a phrase over there.
*The Audio Toolbox plugin is running during this and is buffering, then speaks the phrase when it appears in the buffer.
*The Remote Mouse then clicks on the icon on Windows 10 toolbar to switch back to ARC.
*The Audio Toolbox plugin is turned off.
What stands out to me above are two things:
*The V4 Soundboard is playing at the same time the Audio Toolbox plug is running (Conflict?).
*The Mouse is clicking around all over the place (Com Port conflict like the old Window days? Don't know if this is still an issue now a days. If I recall the mouse and sound card or video display used to have issues with each other sometimes).
Anyway, just some rambling thoughts here to help me work through this. I'll report back later. Feel free to interject any advice. Thanks!
I think the problem I had with ARC disconnecting from wifi had something to do with script timing of the sleep commands. I was not giving things enough time to process. Also it's possible I was not properly stopping the Capture and Listen processes before I tried to restart them again. After some testing I found that not giving commands enough time to execute and not stopping the capture and Listening before restarting them was the only things that caused disconnections.
Thanks to PTP, DJ and Alan for the plugins and help!
Here's a video I took of the end result (so far). It's a little low quality. Sorry but I hope you enjoy:
Sadly the USB Sound card adapter doesn't solve the problem. I am able to get all the sound from the computer to channel through it and play. However the plugin PTP wrote doesn't seem to pick up the audio when running through the USB adapter. I did make sure all settings in windows 10 that I'm aware of point to this adapter for sound playback. Maybe I missed something. When I change back to the laptops default driver and laptop speakers the plugin works like I show in my video. I hear the phase played on the laptop speakers and then 5 seconds later when the buffering catches up I hear it through the EZB in the robot. I even tried using the default laptop driver with the USB Sound Card adapter but no go (Windows Sound Troubleshooter suggested I try this and did it for me).
So for now the way I've eliminated the double talking from the laptop and then from the robot is to attach a set of headphones with it's own volume control in it's cord. That works well. When I plug these headphones in to the laptop's jack the main speaker shuts off. I then just use it's adjustable volume switch to turn the volume all the way down. Walla!
1)
Can you capture a screen shoot of the Device list i.e. Plugin's ComboBox, to see what's being list there.
2) Can you share the amazon link of the usb device ?
As obvious as this probably sounds, plugging a 3.5mm jack which is not connected to anything into the audio socket would cause your laptop speakers to mute just as well, and you wouldn't have to fiddle with the volume control on your headphones.
If you don't have a spare 3.5mm jack laying around, they can be purchased for just a few cents from virtually any electronics or audio store.
Regards
Aceboss, Thanks for that tip. I didn't even think about that. *tired* If pointing to the proper device in PTP's plug in doesn't work I'll just do that.
Aceboss, I just may give your tip a try. Just a wire hanging off the side of the laptop seems much better then a dongle.
Thanks again for the help.
Alan
@ptp
hello, I am having the same issue. I did the steps in the tutorial but I didn't find the plugin I made in the ARC add controls window. How did you solve it?
One of the steps I assume you’re missing could be:
1) output of compile not being put in the plugin folder with folder name of your guid
2) plugin.xml not being copied to output folder
3) plugin.xml not containing the dll filename