|
But what do you want to achieve exactly ?? Measure the time of the sound sample ?
You won't be able to do it like that. Because as I said, if it is run in another thread, you won't be able to access it (even in your MyDirSound class). The thread is ran directly inside the DirectX layers so you don't have access to it. But (fortunately ) there is probably another solution: normally there is something you can find in DirectSound (I suppose, because I don't know DirectSound) that will let you know when the sample is finished. Something like a callback function you can set or something like that. But in this field I have no knowledge so you will need to look in the doc of DirectSound. But I suppose they provided a way to do it...
|
|
|
|
|
Ya.. Thanx cedric.. There is a function called setcallback(..).. I will try it out..
thank you
regards
pallavi
|
|
|
|
|
Hmm, yes but before jumping on that, be sure that this is used to provided a call-back function that will be called when the sample is finished. It could be also a call-back that is called for some other reasons . Maybe also this will be called for several different events and passing an argument that describe which kind of event occurs...
So, before starting writing code, look at the doc to see if it fits what you are seeking for (just to avoid you losing time on things won't work )
Also, if you have time, try to document a little bit about the threads (at least the basics: what it is and how they work, not be able to use them but at least understand what it is).
|
|
|
|
|
In CMyDirSound::Play() .. there is a call ..
m_lpDSB->Play(0, 0, DSBPLAY_LOOPING);// Play(..) member of IDirectSounBuffer
............
I tried saving times before and after this function call.. but both times are same.. all wave files which i am playing are more than 10 secs..
..pal
|
|
|
|
|
See my previous post.
Your function CMyDirSound::Play() is called in the same thread so there is absolutely no reasons AT ALL (I'm not shouting, just insisting on that point ) that it will be ran in a separate thread... You know what a thread is at least ? (I mean, for understanding this, it will be easier for you).
The thread is started inside the function of DirectSound and that's perfectly logical: imagine that all your application will freeze during ten second just because you play a sound
|
|
|
|
|
I try to load .cgm/.wmf file in VC++.The clarity of the image decreases if it is loaded in VC++.But the clarity of the image is retained if it is inserted in MSExcel.Since .wmf is Microsoft supported format it should be of same clarity in both MsExcel and VC++.Pls give me a way so as get the latter's clarity in VC++.
Sudha
|
|
|
|
|
A wmf is a metafile, a sequence of instructions on how to draw an image. It cannot lose quality, all that can happen is if you draw the metafile onto an image smaller than the screen, then stretch that. The problem is almost certainly in how you load and display the metafile as a raster image.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I tried to load the image using render function.Then I tried with playmetafile functions.The problem is that the image drawn is not smooth in either way.But as I told before if we insert the image in MSExcel,it is so smooth.
I want to load a image in .wmf.I want the loaded image to be smoother.Pls send me any code snippets for that.
Sudha
|
|
|
|
|
Hi
I have written an application which includes a timer and a thread. In debug mode everything goes on fine. But in release mode there's chaos. My application freezes when it starts. Please help me.
Regards
Sreekanth Muralidharan
|
|
|
|
|
|
Hello Alok
Thanks a lot for your prompt help. You are really an asset to codeproject.
Regards
Sreekanth Muralidharan
|
|
|
|
|
well dear matez.....
i have developed a software using vc++,it workz fine but.....right now i have been asked to make it "cross-platform" so that it runz in mac os x!.....my question is how do i do that?.....microsoftz api are exclusive to windowz rght?....so how will a code in vc++ work in mac? ....help me out here anyone
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
wxWidgets
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
man, this crap is hard to read.
I recommend telling whoever is asking that they've greatly increased development time by not making this clear up front, and the rewriting it using a GUI framework that exists on both, or Java.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Since memmove() is the only buffer manipulation routine that guaranteed to copy the full source properly, is there any reason why we would want to use memcpy() instead of memmove()? I've since lots of people use memcpy() instead of memmove().
Thanks
|
|
|
|
|
I would say for performance, since memcpy wouldn't be performing the overlap checks. I imagine most of the time the gain would be so small that it's not worth the bother.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
So, you think that we should use memmove() instead?
|
|
|
|
|
memcpy() is slightly quicker because it doesn't do buffer overlap checks, and the compiler is more likely to inline it because the code is a fair bit smaller.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
OH! I'm stuck!
I have no idea what to do !!!
I created a dialog based application (as a matter of fact, my first REAL application).
from the main window I created another option window, over there the user can change the variables (just strings...) to custom his work.
the thing is that when the user will close the application all of his settings in the option window, obviously, will be deleted!
now, what I want to do is to let the user somehow the ability to save his
settings (the variables), and load them into a default file(for the example: "settings.dat" (without using an "open/save file" dialog from the CFileDialog class). in my quest to find the answer I read about serialization, but it really didn't do the job very well... I kept on getting errors and stuff (even by only declaring serialize in COption)
so my plan is: in the OnInit I will check IF the "settings.dat" exist (and I don't really know how to do that), if not, it will be created with default settings (I guess that is just saving, and by that the file will be created),
and if it does exist, it will be loaded.
and in the option window, using:
if(clsOption.DoModal() == IDOK)
in the main dialog, I will save the settings of the options.
so if all I wrote in the above is not a complete bullshit (sorry for the language), technically what I don't know what to do is how to check if the "settings.dat" exists or not, and HOW DO I SAVE AND LOAD???
I know these are big questions, but at least some clue.
I'm REALLY STUCK!
THANKS EVERYBODY!!!
|
|
|
|
|
For lots of different settings, you should use serialization, xml, registry, or something else.
However, in your case, I think you probably just want to save and load a few settings and you are probably just starting the whole GUI business (thats what I understand you mean by "REAL application" ). In that case I would use simple text based input/output to a text file, separating the different settings by some kind of delimeter (ie. a comma, a semi-column, or something like ;mysupercustomdelimiter). When you save to a text file settings.dat for ex., you separate all your settings by a comma. When you load you look for a comma and separate them into different settings. For actual text input/output you could use fstream's (ifstream/ofstream) I think.
This is not a very good solution in general, but it is probably enough to get you rolling.
If somebody feels this is a terrible advice, feel free to correct me and point out a better, SIMPLE way of storing settings.
Get used to getting stuck! It happens on daily basis when programming, at least to me.
|
|
|
|
|
sounds like a simple idea that I can deal with
but how do I read from within the file (the text itself?) and write to that text?
|
|
|
|
|
|
I read about CFile, CArchive and CFileDialog.
I tried what I read about serializing objects (MSDN), but I keep on getting errors on the declaration.
I'm trying to change my approch to this problem and try and use a text file (what the other guy who helped me suggested).
the only thing I can't find is ow to make my app read the text from within the text file.
|
|
|
|
|
Is it safe to have one thread periodically writing to a variable on the heap while another thread is constanly reading that variable?
I have two threads, a worker and GUI.
The worker HAS to be in a loop writing data. Now I need some way of stopping that loop from withing the GUI thread.
I thought, have a common variable "state". Constantly check that variable from withing the worker to make sure it(the worker) should still be working. Whenever I need it to stop, the GUI thread can change the "state" variable to "STOP_STATE" or something among those lines and the next time the worker checks that variable, it stops.
Something tells me this is a very wrong way of syncronizing two threads. Could someone please point me in the right direction.
Thanks in advance,
Nick Z.
|
|
|
|
|
Your situation is a simple one, and the simple solution you propose should be fine. Just make sure that only ever one thread writes to the variable. As soon as multiple threads write to the variable, you'll have to add synchronisation (mutex, critical section etc...) to make sure that multiple writes don't happen concurrently.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|