|
Thank you very much!
Let me show you what I did.
Playing method:
(I've set the buffer to notify me at the half and at the end)
public void PlayingInThread()
{
NotifyPlaying();
playBuffer.Play(0, BufferPlayFlags.Looping);
bool flag = true;
byte[] data;
while (true)
{
arePlaying.WaitOne();
data = jitter.Get();
if (flag)
{
playBuffer.Write(playBufferBytes / 2, data, LockFlag.None);
}
else
{
playBuffer.Write(0, data, LockFlag.None);
}
flag = !flag;
}
}
And I wrote a very simple jitter class, which uses a queue:
class JitterBuffer
{
Queue<byte[]> mBuffer = new Queue<byte[]>();
int mItemLength;
public JitterBuffer(int length)
{
mItemLength = length;
}
public void Put(byte[] data)
{
mBuffer.Enqueue(data);
}
public byte[] Get()
{
if (mBuffer.Count == 0)
return new byte[mItemLength];
else
return mBuffer.Dequeue();
}
}
Am I right up to this point?
Testing this code I saw that there is aproximately one more packet (which can't be played because of the slower playing!) received every second.
So my next question is how to deal with 'too much data available'?
To be honest, I'm not very good at threads and I don't know if it is a good solution but I've tried the following code:
public void CatchUp()
{
if (playBuffer.PlayPosition >= playBufferBytes / 2)
playBuffer.SetCurrentPosition(playBufferBytes-2);
else
playBuffer.SetCurrentPosition(playBufferBytes / 2-2);
}
And I call this method from JitterBuffer.Put() when there are more then 2 packets in the queue. As you can guess in this case I face my initial problems with 'not smooth output'. Maybe I should only drop a packet from the queue when there are a lot?
(What bothers me about the threads is that I manipulate playBuffer from 2 threads in this case. Am I supposed to do it?)
And my last question: should I rely on the notification from a secondary buffer? I've read several times that there are bugs with it.
Regards
|
|
|
|
|
Andrey U wrote: Am I right up to this point?
Yep, that looks like a good way to do things. As Mark says, threading is definitely the right approach (I previously just posted a simplistic method since your original post just had a simple closed play loop). Threading may look complicated, but once you've done a couple of trials you'll probably see that it's fairly simple really
You should perhaps zero-fill your empty buffer in the case where there's no received data, however. It may be cleared in debug builds, but probably will be full of random data (noise) in release.
Andrey U wrote: Maybe I should only drop a packet from the queue when there are a lot? (What bothers me about the threads is that I manipulate playBuffer from 2 threads in this case. Am I supposed to do it?)
You definitely shouldn't operate on the play buffer in anything other than your play thread. I'd also advise against moving the play cursor, since this will definitely cause glitches, and may also cause other problems in playback.
For overruns you can either drop packets, which will also give glitches, although more manageable ones, or you can just play all data - ideally your transmitting app should detect silence and stop sending data, giving the receiver time to catch up during those pauses.
Your buffer size and the reliability of the connection will determine how often you get overruns or underruns, and it's a trade-off between several factors to determine the best size to use. As Mark mentioned, you need to deal with all of these to make a reliable application.
Andrey U wrote: And my last question: should I rely on the notification from a secondary buffer? I've read several times that there are bugs with it.
I've had problems with notifications myself. My last DirectSound system used GetCurrentPosition to check the play cursor at regular intervals, and I found this was much more reliable. (My current project is using XAudio2, which seems to be a lot better.)
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Will all modern versions of Windows honor small changes in playback speed, or are they apt to be rounded up to larger increments? If the sampling PC samples at a constant 8,000Hz, would it be possible to have the playback PC output at a rate slightly faster or slower based upon whether it is getting ahead of or behind the data stream? One would have to be careful, of course, to avoid varying the speed so much as to cause warbling, but I would expect two system clocks should be easily within 0.1% of each other.
|
|
|
|
|
Playback frequency on DSound buffers can be set to integer accuracy, and they'll play properly at whatever pitch is selected.
I'm not sure this is a good approach however. Accurately measuring the rate at which network data is arriving could be pretty difficult, especially since it's arriving in reasonable sized packets, and making continual changes to the frequency could, as you say, cause noticeable unpleasant artefacts.
I've never written a VoIP app myself*, so can only advise in a theoretical way, but I'd go with the approach of playing all data as it arrives, and using silence detection on the transmitting side to signal gaps in the stream during which the playing side can "catch up".
That would be for small (e.g. < 250ms) gaps - for larger ones I'd probably drop some packets, and live with the glitches. VoIP isn't trying to achieve CD quality sound, just reasonably comprehensible speech. Sampling at 8 bit, 8KHz is going to reduce quality quite a lot anyway...
[* My current system is dealing with horrible latencies, multiple streams and multiple buffers, but I'm taking a different approach to dealing with these problems.]
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
|
In addition to molesworth's reply...
1:
I use buffer notifications at 25ms intervals and have had no problems with reliability,
especially XP SP2+. (I've heard no complaints on Windows 2000, but I struggled with network
chunkiness on that OS )
2:
jitter handling:
Dropping packets if necessary is fine if the packets are 25ms - that shouldn't be audible.
If you run out of packets, repeating the last packet written works ok. If you want to go crazy, you can
use interpolation to stretch or compress audio data....kinda overkill for voice.
Molesworth mentioned "Your buffer size and the reliability of the connection will determine
how often you get overruns or underruns". There's also clock drift - two PC's clocks do NOT tick
at the same rate - you'll see (hear)! Over (wall clock) time, the buffer cursors at the endpoints are going to
drift apart. You can hear this if you try to just write every byte of every packet sent to the playback buffer -
either the latency will increase over time or the latency will decrease over time. In both
cases playback eventually turns to garbage when the cursors wrap and/or get out of sync with where you're stuffing
the data.
3:
You should only (and only need to) manipulate the play buffer from one thread - the thread that
responds to buffer notifications and stuffs more data in the buffer.
4:
Let the buffer play and always provide data just ahead of the cursor - you shouldn't and don't need
to adjust the play position during playback. A robust jitter buffer implementation should provide data
whenever requested by the playback thread.
Just tips based on years of doing live multimedia streaming code - hopefully helpful.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Aye - this sort of thing is exactly why we've gone for a third-party solution for voice chat in our next game, rather than dealing with all these complications developing our own...
[ obadvert : APB, coming to a store near you early next year ]
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Andrey,
I am trying to do something similar for a cell phone application.
Would you mind possibly sharing your c# code for recording and
playing back? Thanks.
Benjo
|
|
|
|
|
In a programme there is a follwing error message from the system..
message
"The .Net Data OLE DB Provider(System.Oledb.Data) requires Microsoft Data Access Components(MDAC)version 2.6 or later, version 2.10.3711.9 was found currently installed"
This result the database connection lost,how this problem solve
rajagopal
rajkottayam@rediffmail.com

|
|
|
|
|
based on the error message it looks like you need to install MDAC version 2.6 or later.
|
|
|
|
|
thanks

|
|
|
|
|
Hi Dears,
I have downloaded the code from Code project for Network Sniffer could anyone help me in running the the same.
I am getting the following error in running N/W sniffer.
"An unhandled exception of type 'System.InvalidOperationException' occurred in system.serviceprocess.dll
Additional information: Service SMTPSVC was not found on computer '.'."
Thanks,
Amit
|
|
|
|
|
If you can't figure the problem out by looking at the code yourself, the best thing to do is post in the forum at the bottom of the article that you downloaded the code from, that will get the attention of the person who wrote it. They are more likely to be able to help you.
(On the other hand, if you are just after a network packet sniffer, you could try something like wireshark[^], or one of the ones listed here[^])
Simon
|
|
|
|
|
Hello every one,
I am developing an application using asp.net
my requirements like
* on server there will be web application and at client side there will be an device
* web application is using asp.net and client application is using C++
* server and client are connected using GPRS.
* when user will login in web application, then there will be list of device which is present on different different locations.
* user can select particular device and after click on connect button, communication will start between server and client.
* after establishing the connection client can send log file to server or there is both way communication
my issue is only for web application. Like how can i make connection and how to communicate with client
should i use webservice for this? or how to achive this..!
Please help me on this
Thanks in advance
|
|
|
|
|
hello
If u want to make the communication with device(i hope ur device will be physically connected with machine so they would b able to work remotely)you should do the port programming. because ports are areas where from connection can be established.
Rohit Sharma
|
|
|
|
|
Hi,
I am having a project to build a toolbar for IE that doesn't require any installation, a bit like Digg Bar. Does anybody know how to do it and what technologies should be used?
Thanks for your help.
ZL
|
|
|
|
|
Hi,
I am having a project to build a toolbar for IE that doesn't require any installation, a bit like Digg Bar. Does anybody know how to do it and what technologies should be used?
Thanks for your help.
ZL
|
|
|
|
|
Hello
I have an iPAQ 114 with Windows Mobile 6 Classic.
I have developped an app with NETCF 3.5
If I use Visual Studio 2008 and debug, it implements NETCF 3.5 on the device without error.
If I copy NETCFv35.wm.armv4i.cab on the device and I try to run it, it shows me an error message because it is not digitally signed with a trusted certificate (it's Micosoft program on Microsoft OS ).
I have tried to reduce the security configuration with Visual Studio 2008 and I have left no security. But I have the same error.
Only if I debug, I can install NETCF 3.5
I need to make it without Visual Studio because the final user don't have Visual Studio and I need he can make click on the NETCFv35.wm.armv4i.cab file to install it.
Any suggestion?
Thanks in advance
modified on Monday, June 1, 2009 9:08 AM
|
|
|
|
|
i also facing this problem in windows mobile 6.1 while i install .NETCF3.5 
|
|
|
|
|
Hi,
In my project, i was allocated into a database convertion work (ie we have a client db(it may be a Mainframe Db) and i have to convert it into Ms-access db) using VB.NET.
We have a set of client db files which are having the below mentioned format.
.hed, .inf, .chr, .idx, and .tad
Please kindly share your ideas and codes to complete this development successfully...
Actually i am new to .NET development...Now i am learning the VB.NET concepts for the purpose of this dev.
Thanks,
Sivakumar.M
|
|
|
|
|
sivakumar.mariappan wrote: it may be a Mainframe Db
First find out exactly what the DBMS is, we can't help you if we don't know what you are working with.
|
|
|
|
|
As i mentioned, it is client's own DBMS (DBMS is INF*ACT DB). It is not derived from any other dbms like mainframe, sqlserver and oracle. Just now i got this details from my colleagues.
All this database informations are available inside of these five file format's only.
.hed, .chr, .tad, .inf and .idx
If you want, i will send the sample files to you.. But i don't know how to attach the files with this forum.
Thanks,
Sivakumar.M.
|
|
|
|
|
You basically have two choices:
1. Implement something that understands the binary structure of these files and extract the data out of them.
2. Extract the data out of the DB, and import the data manually.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
As you advised, I have collected some more details about this inf*act db which are given below.
Nielsen Inf*Act db is a SQL db compatible with relational Star schema Data model. It is client's own dbms.
We are receiving the inf*act db datasource from the client in a folder(the folder should be in country code) and this folder contain the files with the formats of .hed,.chr,.idx,.inf and .tad(5 files for each DB).
If the datasource dump has 50 db means, the datasource folder will contain (50dbs*5files for each db) 250 files. We are adding each database through our tool by browsing the file in the format of (.hed ) from this datasource folder.
One important thing is, if we delete any one of the file among those 5 files(.hed,.chr,.idx,.inf and .tad) for a db, the database will not get added in our report template tool.
As i discussed here, the data is available in <b>.inf</b> file. First i have to extract the data from this file. Then only i can import them into ms-access.
So, <b>i want the code in vb.net, that how to extract the data from this file and import them in ms-access.</b>
I think this will help you a lot
Thanks,
Sivakumar.M
|
|
|
|
|
sivakumar.mariappan wrote: I think this will help you a lot
Nope. I'm not writing your code for you - that's your job. This isn't rentacoder where you get some dumbnut to write code for you, and I don't get paid to do your job for you. Tell you what, put me in touch with your client, and my company will do the work for them directly - we'll even throw in a support contract for them.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|