Solved

Steaming audio over winsock

Posted on 2004-03-30
7
1,491 Views
Last Modified: 2013-11-13
Hi,

I have worked with winsock in VB many times before, but never for a purpose as complex as this.
I have 2 programs, serverside and clientside (running on seperate machines.) There is already a TCP winsock link between the two, sending simple text strings between each other. I want to setup up a second winsock link and with this i want to stream all the audio from the client to the server. This doesn't just mean Wave audio, but also Mic and Line-In audio too (just them three will do, but if its easier to stream all the audio then thats ok too.) I understand how to setup up the winsock link and connect, but the audio is a problem.
I assume that sound is handled at 44.1Khz 16bit (could be wrong,) if it is handled this way, then there is no need to downsample it (although downsampling it to 22.05Khz 8bit would be ideal if its not too difficult to code and not too CPU hungry when running, as this will cut down on LAN traffic.) However, the audio should preferably be converted to mono before sending (this isn't absolutly essential, so if its much easier left as stereo, then it can be left as stereo.) The audio then needs to be sent over winsock. When the server receives the data, it should output the audio to the default sound device (and so play the clients audio out through the servers speakers.)

The audio needs to be constantly streaming with as little delay as possible.
I am only assuming winsock is the way to go with this, I cant think of any other methods of communicating the data, although if there is a better way that i dont know about then im open to suggestions- It'll be another lil bit of VB knowledge for me :)

Really needing help with this please. Ive been trying to figure this out for ages but i don't even know where to start with the audio bits n pieces. I figured the way to do it was for the clientside program to somehow capture the audio stream and convert each sample to an ASCII charactor that represents the sample, then send this over winsock (or wait for a certain number of samples to be processed and compile a string representing all these samples, and then send it.) On data arrival, the server would convert the ASCII string back to samples, then somehow output each sample one at a time to the default sound device at the same frequency the client is processing at.
I don't know if thats at all close to how its really done, but it was just how I imagined it.
Another method at the server side would be to write the incoming data to a wav file and play the file (I came up with this method as i didnt know how to directly output to the sound device, but i knew how to play wav files in my programs.) You'd have to use two files, one to write to as the other plays, and keep switching between the two. The problem with this method is that with the constant file reading and writing, there may be slight delays which would not only cause hiccups in the audio, but may accumilate and cause a forever-increasing audio delay (and thus hogging memory as the line of queued samples gets longer and longer.) Plus, there may be slight delays between playing the first file and the next file. I suppose you could just cause the file playback to be asyncronus and play each file on time whether the other file had finished or not, although you still have the delay caused by reading and writing to harddisk and now you have slight overlaps before each file finishes, so consequently you end up with poor audio quality as it hiccups thousands of times a second.

Anyways, back to the problem in hand....  

Thanks for your help in advance,
Matt :)
0
Comment
Question by:pyromatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10722678
Well the easiest way to "steam audio" I believe would be to record a 1-2 second sample, then save it as a wave file, send the file over winsock as binary, save it on client side, play and delete.

I've never done this before, and I am sure there is a more effiecent method, but maybe this will work for u.

Just a suggestion.
-Brian
0
 

Author Comment

by:pyromatt
ID: 10722811
Yeh i was thinking about that, but the delays too long. i need less than 200ms delay really.

Thanks for the suggestion though :)
0
 

Author Comment

by:pyromatt
ID: 10722840
LOL! just realised the "steaming" bit... it was half 8 in the morning, i was probly still asleep when i wrote this.... heh
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 3

Expert Comment

by:pg_india
ID: 10723117
just a guess, can use ftp objects for this...
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 10724691
Sounds like a good candidate for DirectPlay Voice.  There is a sample app here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=24593&lngWId=1

I've never used this technology before so I can't help you out though.

Idle_Mind
0
 

Author Comment

by:pyromatt
ID: 10728312
that app only demonstrates multiple winsock links, not streaming audio.

At long last, (16hrs later) i found a great solution to this problem!
for those of you who are interested, download this...
http://www.devcity.net/forums/attachment.asp?id=634
when extracted, ull find the zip contains 2 projects, placed in two seperate folders. the wavestream dll project must be compiled first and then you can use the actual application itself (although you'll need to reconfigure the reference to the wavestream dll as it looks for it in the wrong place.)
id highly recommend this as the entire project is explained step by step with comments. It also supports the use of several different codecs and several simultaneous winsock links, plus loads more features.
its excellent!
 
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 10729694
User resolved; points (350) refunded and question closed.

Netminder
Site Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 135
vb6 connector to mongodb 2 162
Math Equation 23 149
how to Classify of email (pdf attachments) 7 57
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question