|
Ben Magee wrote: would that work any better?
Would what work? And better how?
You need to show the extract of the code where the problem occurs, and the full description or text of the exception. The question above really makes almost no sense whatever, and even less in the context of your original question.
Read through a few more of the posts here to get an idea of the sort of questions that get resolved quickly.
|
|
|
|
|
Hi all,
I am using DirectSound to play wav files, one at a time or several together and it is all ok:
...
Device device = new Device();
device.SetCooperativeLevel(this, CooperativeLevel.Priority);
BufferDescription bDesc = new BufferDescription()
...
SecondaryBuffer sBuffer = new SecondaryBuffer("Wavefile.wav", bDesc , device);
...
sBuffer.SetCurrentPosition(0);
sBuffer.Play(0, PlayFlags);
...
sBuffer.Stop();
If i want to play multiple wav files (very short - max 5 seconds) that each start at a defined time and can overlapp eachothers (Like all mixer applications - Adobe Audition ...)
ex:
Wav1 start at time 0 second and ends at time 4 seconds,
Wav2 start at time 2 sec and ends at 7 sec,
Wav1 start at time 3 sec and ends at 7 sec,
Wav3 start at time 5 sec and ends at 6 sec,
.....
Using several SecondaryBuffers and playing them at the same time will play all the files simultaneously but not in a controled time order (which is very important).
How can i control the SecondaryBuffers to play simultaneously these short wavFiles at a specific time ?
Thanks for your reply
|
|
|
|
|
I will create a class say WavFile which represents a single wav file. This will have methods like Play() and Stop() and properties like StartAt and EndAt . To control all wav files, a WavController class can be created which maintains a collection of wav files that has to be played.
WavController maintains the start time and in a loop it calculates the elapsed seconds. Each time the wav file collection will be queried to get the wav files that matches to the elapsed seconds. You need to get objects that has to be played and stopped for the elapsed second. Call Play() or Stop() on those objects which will eventually call DirectSound's stop/play methods.
WavController should run the loop on a separate thread and it should exit safely when all files are played rather than aborting the thread.
|
|
|
|
|
Thanks for your fast reply,
I am new to DirectSound, so sorry for my beginner questions. I wonder if your described solution using threads is the "only one" to do this:
For example, if there is a way in creating multiple SecondaryBuffers and then "mix" them all in one Primary buffer (at the right time) and play the Primary buffer ?
or if is there another solution!!!
Thanks
|
|
|
|
|
Zorro000 wrote: f there is a way in creating multiple SecondaryBuffers and then "mix" them all in one Primary buffer
Like you, I don't have much knowledge on directsound.
|
|
|
|
|
hi all... me trying to make a C# appln that runs in two systems simultaneously... if an user A gives the ip address of a user B running the appln and press a button Bu the userB must get an alert saying that the button BU is pressed by usr A... would someone help me with this coding???either tcp or udp will do... pl help me out with ths part... thanx
|
|
|
|
|
You asked this once already.
|
|
|
|
|
No one is really going to hand you over for coding for such an application, you can google peer 2 peer .net messaging or something similar to try to find something that is similar and opensource, if your job/teacher has a deadline then go to www.rentacoder.com and don't try to low-ball the coders!
|
|
|
|
|
Unless it's all over LAN, you will have a NAT problem.
(yea I know that's not an answer, it's more of a tip)
|
|
|
|
|
hi all... me trying to make a C# appln that runs in two systems simultaneously... if an user A gives the ip address of a user B running the appln and press a button B the userB must get an alert saying that the button is pressed by usr A... would someone help me with this coding???either tcp or udp will do... pl help me out with ths part... thanx
|
|
|
|
|
That's a homework kind of question. Here are few points to get you started.
1) System.Net.Sockets[^] namespace provides various classes which can be used to do network programming.
2) For TCP, start with TcpListener and TcpClient classes.
3) For UDP, look at UdpClient class.
|
|
|
|
|
Hi:
I have looked over the material I can find on programatically installing and uninstalling type fonts in windows but I must be missing some pieces to the puzzle.
Here is an example of what I seem to not be able to compile in Visual C# 2008
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/dd2e5ccc-3f6e-4c73-8bf8-565b18107a5a/[^]
and I can find no information on the AddFontResource method nor is it recognized in my namespace.
Any advice would be helpful.
|
|
|
|
|
HighCloud wrote: Here is an example of what I seem to not be able to compile in Visual C# 2008
What errors does the compiler give you?
HighCloud wrote: I can find no information on the AddFontResource method nor is it recognized in my namespace.
AddFontResource is a Windows API function that is invoked through the PInvoke call in C#. See here[^] for details.
|
|
|
|
|
Thanks for your reply.
Being somewhat of a beginner, my main problem is that I can not seem to find any using statement or reference that will recognize these functions:
AddFontResource()
SendMessage()
WriteProfileString()
The example link in my previous post shows an external declaration.
Another example that has come up from sources on the internet is a statement such as:
FontInstall.AddFontResource();
Prehaps I do not need them at all, but learn how to use the API.
Please comment.
|
|
|
|
|
Hi,
P/Invoke is the way to access existing native functions, in this case they reside in system files gdi32.dll and user32.dll; the "extern" keyword tells the C# compiler only a prototype is provided, the implementation is to be found in those DLL files.
What seems to be missing in the article is the fact that your code should start with a statement
using System.Runtime.InteropServices; for the compiler to understand what DllImport means.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thankyou. You are right. That was a missing piece for me.
Now that you have told me about the PInvoke, I looked that up on the MSDN web site and they have a tutorial there which I will study.
a couple of questions that I have right now is:
do I copy the dll's from my system directory to my project to use them?
Is this the best way to install a type font programatically?
|
|
|
|
|
See here[^] for some good information on the AddFontResource function, and PInvoke in general.
HighCloud wrote: do I copy the dll's from my system directory to my project to use them?
No, the runtime system knows where to find them.
HighCloud wrote: Is this the best way to install a type font programatically?
I'm not sure of the answer to this one, but there are some useful articles on Fonts here on CP.
|
|
|
|
|
Thanks again.
I believe that for now I have enough information to compile and experiment with this material.
|
|
|
|
|
Hi,
could you provide the P/Invoke link? I am in the middle of writing an article on the subject, and eager to get more material.
FYI: you don't have to install a font to use it in your own app, there is a PrivateFontCollection class that could help you out. (I haven't used it myself though).
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
See my previous answer; it's PInvoke.net. Surprised that you didn't know about this, I felt sure you would have written some of it. 
|
|
|
|
|
Sorry, I misunderstood. I have known and like pinvoke.net for years (even when it has some errors); I am looking more for tutorial material though.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I must admit to being somewhat surprised that you did not know about it. Unfortunately it's my only source, although some of the entries do contain some quite useful sample code.
|
|
|
|
|
As I said before, I have been using www.pinvoke.net for many years. It offers reasonable reference material, somewhat incomplete and sometimes plain wrong.
I would like to see better P/Invoke tutorial stuff e.g. explaining all the Marshaling alternatives, and that is why I am writing my own article right now.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: and that is why I am writing my own article right now.
Excellent news; I'm looking for a decent tutorial 
|
|
|
|
|
Would you be interested in proofreading and providing feedback?
I plan a two-part article, of which the first part is almost ready (except for the download).
It contains general principles and many simple examples (C# so far, will be adding VB.NET), but skips everything about structs.
BTW: not sure I will publish it on CP as the house style doesn't really fit; I'll have to take that up with Chris in a couple of weeks.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|