|
Hi all,
what I'm trying to do, and failing obviously, is to create .wav files from .raw files (plain text files, just full of integers).
the problem is that I dont know how to create the header for the wav file properly. I'm going to be creating the same type of wav file all the time, ie 16khz, mono, 8-bit unsigned.
What I'm doing so far is using the fstream function but I'm not sure how to calculate all the required information from the .raw file.
The only change will be the size of the file, so I think that a fairly generic header would do the job, with the only thing having to change being the samples.
Can anyone help me here, I've looked around but still lost.
Thanks in advance all,
Chris
|
|
|
|
|
This[^]has everything you will need, I think. Goes into a detailed header description, too.
Have fun and maybe use it to write an article
If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
I just had a look at the code injected by the compiler when using the __event, __hook and
__raise keywords on native C++ code. The sample in the help-files which come with VC 7.0
define a void-event like so;
__event void MyEvent( int value );
and __hook a reciever to it and subsequently __raise it.
Fine.
So I changed it to this;
__event int MyEvent( int value );
and looked at the generated code for the __raise, ( now returning an int ), which is like so;
<br />
inline void CSource::MyEvent(int i1) <br />
{<br />
__EventingCS.Lock();<br />
__eventNode_CSource_MyEvent* node = __eventHandlerList_CSource_MyEvent;<br />
<br />
int hr = (int) 0;<br />
for (; node != 0; node = node->next) <br />
{<br />
hr = node->__invoke(i1);<br />
if ( hr!=0 )<br />
{<br />
return hr;
}<br />
}<br />
<br />
__EventingCS.Unlock();<br />
<br />
return hr;<br />
}<br />
( that comment is mine, not MS' ),
Is it just me or is this code broken ? The only way this code is not broken is
if there is some secret exception handling semantics going on which I don't know about.
If that's the case I stand corrected.
However, if it is not, then that piece of code will die somewhere bad due to a deadlock.
Anyone ?
cheers
-=jarl=-
----------------------------
jarl ostensen
Lead Technology Programmer
Bullfrog/Electronic Arts Inc.
|
|
|
|
|
Hi,
I execute my pgm two times .
I would like to know how can I do for inhibe the second pgm execution
I would like to show the first pgm and close the second pgm.
Best Regards
youssef
|
|
|
|
|
Here is a very extensive article on what you want to do by Joseph M. Newcomer. Check it out.
Avoiding Multiple Instances of an Application[^]
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
A member posted a simular question at CodeGuru. Here is the thread.
http://www.codeguru.com/forum/showthread.php?s=&threadid=221071
Kuphryn
|
|
|
|
|
im having this strange problem with a program im developing.
The program compiles & links with 0 errors, and 0 warnings on both Debug, and Release Configurations.
The Problem is midway thru execution of the main function on my Release Compile , I get one of those mysterious MFC error dialog boxes (send / dont send to microsoft) that doesnt really tell me much about the problem....
the code that this error is contained in is .......(sorry , i know its a little hard to read this way, this text box takes out the formatting... )
/// here will start the directory iteration
for (int ji=0;ji<fia.GetSize();ji++) {
char *c1 = new char[100000];
//read into c1
FILE *input;
if ( (input = fopen( fia[ji].GetFilePath(), "r" ) ) == NULL )
{
AfxMessageBox( "Could not open file....\n" );
}
numread = fread( c1, sizeof( char ), 100000, input );
c1[++numread] = '\0';
fclose( input );
// call api function
if(NULL != dllHandle)
{
// If the function address is valid, call the api's function.
if (runTimeLinkSuccess = (NULL != BounceCheckPtr))
{
result = BounceCheckPtr(*c1, *c2, len, *c3, *c4);
}
}
///// prepare database entry
UCHAR szSqlStr[128];
if (result == 0) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('GB', '%s')",c2);
}
if (result == 1) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('HB', '%s')",c2);
}
if (result == 2) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('SB', '%s')",c2);
}
if (result == 3) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('GB', '%s')",c2);
}
if (result == 9) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('GB', '%s')",c2);
}
// set return code
int m_iIdentification_Code = result;
// Switch Structure
switch( m_iIdentification_Code )
{
case 1:
// Allocate memory for the statement handle
retcode = SQLAllocStmt (hDBC, &hStmt);
// Prepare the SQL statement by assigning it to the statement handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
// Execute the SQL statement handle
retcode = SQLExecute (hStmt);
// Project only column 1 which is the models
SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel), &cbModel);
// Get row of data from the result set defined above in the statement
retcode = SQLFetch (hStmt);
// Free the allocated statement handle
SQLFreeStmt (hStmt, SQL_DROP);
break;
default:;
}
// delete memory i create on heap
delete[] c1;
}
it loops once, and then it dies on the second file read section...
any ideas / suggestions... would be appreciated
|
|
|
|
|
Just having a quick look; ye code looks a bit dodgy;
<br />
numread = fread( c1, sizeof( char ), 100000, input ); <br />
c1[++numread] = '\0';<br />
which can lead to
<br />
if numread==100000 )<br />
{<br />
DoOverwritePseudoRandomMemory( '\0' );<br />
}<br />
in debug-build you would have some pad-bytes which might silently swallow this.
Don't know if this is the problem, but it certainly can be a problem.
-=jarl
----------------------------
jarl ostensen
Lead Technology Programmer
Bullfrog/Electronic Arts Inc.
|
|
|
|
|
jDawwg wrote:
char *c1 = new char[100000];
jDawwg wrote:
FILE *input;
if ( (input = fopen( fia[ji].GetFilePath(), "r" ) ) == NULL )
Why are you using C style file handling and fixed size buffers ? If you use iostreams and std::string, you can do this so much nicer, and without there being any risk of a buffer overrun or truncated read, nor would you allocate a huge buffer that you do not need.
jDawwg wrote:
retcode = SQLAllocStmt (hDBC, &hStmt);
// Prepare the SQL statement by assigning it to the statement handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
// Execute the SQL statement handle
retcode = SQLExecute (hStmt);
// Project only column 1 which is the models
SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel), &cbModel);
// Get row of data from the result set defined above in the statement
retcode = SQLFetch (hStmt);
// Free the allocated statement handle
SQLFreeStmt (hStmt, SQL_DROP);
What is the point of grabbing the error status if you never check it ?
jDawwg wrote:
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('GB', '%s')",c2);
I think that &szSqlStr[0] is nicer syntax, but that's just me.
I reckon if you used C++ file handling and strings, your problem would probably go away.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Excellant ! thanks for the help Chris / Jarl! !
(jarl, thanks for the followup email too)
Im going to implement these suggestions and ill update you on how it goes..
i appreciate all the tips on making my code better too, because Im not really a c++ expert (yet, im optimistic ). the current experience I do have w/C++ has been hacking together projects out of neccessity so im sure its sloppy....
|
|
|
|
|
jDawwg wrote:
appreciate all the tips on making my code better too, because Im not really a c++ expert (yet, im optimistic ).
So long as you maintain this attitude, you will end up being better than most. Good luck !!
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hello,
I want to change the caption of my Property Page at runtime.
SetWindowText does not the trick. The Caption Text specified
in the Dialog editor is always used, no change after a SetWindowText
call in OnInitDialog.
Any Idea ?
|
|
|
|
|
Wow - deja vu, I am having the EXACT SAME PROBLEM. Although my scenario is a little different - my property page is in Wizard mode.
If you know the new title when the constructor of the property page is called, you can put this in the property page constructor:
<br />
m_psp.dwFlags |= PSP_USETITLE;<br />
m_psp.pszTitle = "Some New Title";<br />
BUT... this will NOT work after the property page has already been created! If anyone knows of a way to change the property page title (especailly in a wizard-mode property page) at run-time (NOT in the constructor) that actually works, I'm all ears.
I hate property sheets.. one of these days I'll write my own custom version of them and avoid all the silly restrictions they have.
Even a broken clock is right twice a day.
|
|
|
|
|
|
Cool,
it works for me too.
Thanks
|
|
|
|
|
There is a PROPSHEETPAGE pointed to by the m_psp class member of a property. This contains a field
pszTitle which contains the the title of the property page. Yoy will need to set the PSP_USETITLE flag in the dwflags of the property sheet to use this. You might give this a try.
|
|
|
|
|
The following is my code:
CAsyncSocket socksrv;
char buff[500];
...
UINT ClientThread(LPVOID lParam)
{
CSocket* s = new CSocket;
s = (CSocket*) lParam;
while (1) {
s->Receive(buff, 500*sizeof(char), 0);
if (strlen(buff)) {
::SetFocus(NULL);
AfxMessageBox(buff);
}
}
return 0;
}
UINT ServerThread(LPVOID lParam)
{
CSocket s;
socksrv.Create(55599);
socksrv.Listen();
while (1) {
if (socksrv.Accept(s)) {
AfxBeginThread(ClientThread, (LPVOID) &s);
}
}
return 0;
}
void CServerDlg::OnStartServer()
{
AfxBeginThread(ServerThread, NULL);
}
When I execute the following, and try to connect the client, an exception occurs. Please tell me where my mistake is, and if you know what the multithreading sequence must be using CSocket or CAsyncSocket...
Thank you!
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Vladimir Georgiev wrote:
if you know what the multithreading sequence must be using CSocket or CAsyncSocket
Never use MFC socket classes in Multithreaded environment, otherwise you'll be between the devil and the deep sea. MFC not allows you to pass CSocket/CAsync objects directly from one thread to another. You have to use references for that purpose. Have a look here[^]
|
|
|
|
|
Hi,
In my dialog-based program, I am creating a CComboBox with some
data that I read from a file. So this is a case where I cannot
use the resource editor. But now that I have it created, I am
finding nothing in the documentation (I am new to VC++) which
explains how to receive and process events when the user selects
a new item in the combo box. Can anyone explain this very basic
concept to me? A friend of a friend says I have to something
with a message map, but doesn't know precisely what. Any help
would help.
Thanks!
x66u
|
|
|
|
|
In the case of MFC, you will need to add the message map entries/function prototypes for the control manually.
If you create the control with an ID of IDC_MYCOMBO you would use for example
afx_msg void OnSelChangeMyCombo();
ON_CBN_SELCHANGE(IDC_MYCOMBO, OnSelChangeMyCombo)
void CYourClass::OnSelChangeMyCombo()
{
}
...
The other message map entries for a combo box are (from MSDN):
Combo Box Handlers
Map Entry Function Prototype
ON_CBN_CLOSEUP( <id>, <memberfxn> ) afx_msg void memberFxn( )
ON_CBN_DBLCLK( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_DROPDOWN( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_EDITCHANGE( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_EDITUPDATE( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_ERRSPACE( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_KILLFOCUS( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_SELCHANGE( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_SELENDCANCEL( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_SELENDOK( <id>, <memberfxn> ) afx_msg void memberFxn( );
ON_CBN_SETFOCUS( <id>, <memberfxn> ) afx_msg void memberFxn( );
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Hello,
I've discovered that the lower menubar in WinCE for PocketPC
is in fact a toolbar. Fine there, but now I am wondering
how to add a popup menu to it. Can anyone point me to some
minimalist sample code that implements such a thing?
Thanks very much!
x66u
|
|
|
|
|
Hi all,
I hope this is the right forum to ask, I want to do it from C++ so I figured I could try here )
I'm trying to get an image from an html page that I have in memory. IWebBrowser2 doesn't let me do that AFAIK, it looks like I even have to actually create a window to use it. I just want to pass a string with html to some function, and have that function return a bitmap (with specifyable width & height ofcourse). I would prefer to use IE to do it, since I need to render MathML. Any thoughts? Thanks in advance.
cheers,
roel
|
|
|
|
|
I think you need to query for the interface to the DOM--
that's an IHTMLDocument2. It should allow access to the
images.
oh yeah... a link to example[^].
|
|
|
|
|
oh wait. did you want an image on the page or an image of the page.
|
|
|
|
|
Yeah I wanted an image _of_ the page... Thanks for replying anyway
|
|
|
|
|