|
Look around on the former Dialogic Corp's support website. There is some sample code there to do ADPCM to WAV, not exactly wat you want but a good starting point. PCM should be pretty much a sraight series of linear samples, so you just need to figure out what he proper WAV encoding is going to be. I'm not sure what this True Speech is, but a standard WAV file is usually stored as PCM. In that case there really is no conversion, just a file format change. Hope this helps some..
|
|
|
|
|
My program creates an object of CList, the nodes of which contains CMessage class object. The file has two functions, Write2List() and ReadFromList().After executing the program,i get no errors. But if i debug the program, i get "Unhandled Exception-0xC0000005:Access Violation" error after coming out of the ReadFromList(). Please help.
The code is as follows
include <memory.h>
#include <afxtempl.h>
#include <iostream.h>
class CMessage
{
public:
unsigned char m_cnt, m_mid;
public:
//constructor
CMessage();
CMessage(unsigned char nCnt, unsigned char nMid, unsigned char* pdata);
//destructor
~CMessage();
void SetValues(unsigned char nCnt, unsigned char nMid, unsigned char* pdata);
int GetData(unsigned char* pdata);
private:
unsigned char m_data[4]; //body of the message
};
CMessage::CMessage()
{
}
CMessage::CMessage(unsigned char nCnt, unsigned char nMid, unsigned char* pData)
: m_cnt(nCnt), m_mid(nMid)
{
for(int i=0; i <= ( m_cnt - 2); i++)
m_data[i] = *pData++;
}
CMessage::~CMessage()
{
// m_cnt = '\0';
// m_mid = '\0';
// memcpy(m_data,'\0',16);
}
void CMessage::SetValues(unsigned char nCnt, unsigned char nMid, unsigned char* pdata)
{
m_cnt = nCnt;
m_mid = nMid;
for(int i=0; i <= ( m_cnt - 2); i++)
m_data[i] = *pdata++;
}
int CMessage::GetData(unsigned char* pdata)
{
for(int i=0; i <= ( m_cnt - 2 ); i++)
*pdata++ = m_data[i];
return 0;
}//end of class CMessage
//typedef for our list template.
//Type is CMessage
CList<CMessage, CMessage&> myList;
void Write2List()//CMessage* pMessage1)
{
unsigned char data[4];
data[0] = 0x01;
data[1] = 0x02;
data[2] = 0x00;
data[3] = 0x04;
//first time of Initialisation
CMessage* pMessage = new CMessage();
//setting values thru the function.
pMessage->m_cnt = 0x40;
pMessage->m_mid = 0x30;
pMessage->SetValues(0x20,0x41,data);
myList.AddTail(*pMessage);
}
void ReadFromList()
{
unsigned char data[10], mCnt,mMid;
CMessage pMess;
while(myList.GetCount() != 1)
{
pMess = myList.GetAt(myList.GetHeadPosition());
mCnt = pMess.m_cnt;
mMid = pMess.m_mid;
pMess.GetData(data);
myList.RemoveHead();
}
cout<<"abc"<<endl;
cout<<(int)data[0]<<endl;
}
void main()
{
Write2List();
Write2List();
cout<<"ABC"<<endl;
ReadFromList();
cout<<"XYZ";
}
Roopa
|
|
|
|
|
pMessage->SetValues(0x20,0x41,data); This line in Write2List seems to indicate that data is 0x20-2=20 bytes long, yet it contains only 4 bytes. This might be causing the error.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank u very much for ur help. Now it is working fine
Roopa
|
|
|
|
|
As an aside, it would make your life a lot easier if you use STL for your collection classes inside of the MFC collection junk.
|
|
|
|
|
Greetings all,
Can someone tell me if there is a way to watch the activity on a port with out issuing the 'listen' call.
I am building a small app (to run on windows) that listens on port 80, but I don't want to (can't) allow both the server and my app to 'listen' on the same port and I don't want to interfere with the servers performance. Can somone enlighten me on a way to do this.
|
|
|
|
|
You need to write a sniffer for that. Check the Platform SDK for some socket options which allow you to open a raw socket.
HTH
|
|
|
|
|
i encounter an problem: i need to Update one database on following conditions:
1. if the application is running at 0:0am in the morning ,it should update the database;
2.everyday the first time to start the application ,it should update the database;
3.everyday the database should be updated only once.
as far as i have thought about, i don't want to use the Task schedular ,also i am bored to handle WM_TIMER .
then can anybody tell me what to do by rule of thumb?
thanks in advance !
|
|
|
|
|
Hi everyone
I wonder if there is any embedded implementaion or helper class of Regular Expression in VC/C++? Or any third part surport?
I've heard that Regular Expression is used a lot by compliers. So can we use the complier as the embedded intepreter of Regular Expression? If we can, how?
Thank you. Waiting for your help.
|
|
|
|
|
there are libraries (i never used)
try search for regex, regexp++ etc. (see http://www.codeproject.com/string/re.asp or sourceforge.net)
t!
|
|
|
|
|
I've used the Regex classes in boost (www.boost.org) - they seem to work pretty well. There's also the Greta library from some guy @ Microsoft (go to research.microsoft.com & search for 'Greta')
Hope these help...
|
|
|
|
|
I've heard something to the effect that these two very implementations are the ones competing for a place in the C++0x library. As with all rumours one should take them with a grain of salt, but perhaps it could be something to plan for.
|
|
|
|
|
You can use Regular Expression with ATL 7. I forgot the name of the new classes
but go to MSDN, you can have more details.
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
|
Thank you all. These are really helpful.
But there is really a petty about using boost. When I've installed it, I find the RE implementaion relies on some DLL objects. That introduces the installation problem because I want to build a COM server that depends on nothing except using static linking.
Maybe I should try ATL 7, as Ernest suggested.
|
|
|
|
|
You can build the regular expression library in Boost as a static link library - Boost Regex should pick that if you're statically linking to the C run-time. To force use of the static library, put
#define BOOST_REGEX_STATIC_LINK
in your stdafx.h (or as a command-line argument to the compiler, whatever). It does work, believe me - I've been through all that (used it in a small WTL app. that I wanted to have minimal DLL dependencies...)
|
|
|
|
|
It provide DesktopColorizer.dsw demo From www.softshape.com , we can move the entire window in client , now I want to nomove the window , What can I do it ?
sai of china
|
|
|
|
|
Say I have a Bitmap resource IDB_BITMAP1
How do I draw this bitmap onto my CView ?
Regards
Nish
p.s. did some quick searches on CP. Saw some classes. I dont want any classes. Want some code pointers
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Check out my screen saver I take the CP logo from a resource and draw it on the screen. Drawing to a CView is just like drawing to any old window (only you'd use the MFC DC wrappers of course).
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork-100.10414 AcidHelm
|
|
|
|
|
Hi Mike
I got it to work on my own with some trial/error. But I am worried about leaks
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Okay, after some fiddling I came up with this. It works, but is it okay?
CDC mdc;
mdc.CreateCompatibleDC(pDC);
CBitmap b;
b.LoadBitmap(IDB_BITMAP1);
BITMAP bmap;
b.GetBitmap(&bmap);
CSize s = CSize(bmap.bmWidth,bmap.bmHeight);
mdc.SelectObject(&b);
pDC->BitBlt(0,0,s.cx,s.cy,&mdc,0,0,SRCCOPY );
I am not deleting or releasing the CBitmap or the CDC as I assume their destructors will do it for me. is that a valid assumption?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
When b's destructor is called, the bitmap is still selected into mdc device context. ::DeleteObject call silently fails and you have resource leak. You have to ensure that b isn't selected into any context when its C++ d'tor is executed. The tricky way is to change order of declarations of mdc and b. If mdc is second, it'll be destroyed first and your bitmap will be released.
Or - you can store CBitmap* returned from mdc.SelectObject call and re-select it after BitBlt.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Hello Tomasz, I realized that. So I did this :-
CDC mdc;
mdc.CreateCompatibleDC(pDC);
CBitmap b;
b.LoadBitmap(IDB_BITMAP1);
BITMAP bmap;
b.GetBitmap(&bmap);
CSize s = CSize(bmap.bmWidth,bmap.bmHeight);
mdc.SelectObject(&b);
pDC->BitBlt(0,0,s.cx,s.cy,&mdc,0,0,SRCCOPY );
b.DeleteObject();
I have added b.DeleteObject() and I hope that'll avoid the situation you predict
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Sorry - this will not work. b is selected into mdc when you're calling DeleteObject; the call fails. GDI doesn't allow deletions on objects (brushes, pens, bitmaps, etc) selected into any device context.
DeleteObject call doesn't make any difference - CBitmap d'tor calls it anyway.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thanks Tomasz. I alreday sent the prototype. But the leak is a once only leak. You see, when the app starts up there is no msp file loaded and thus no image to show. So I addeda default bitmap resource and was showing it. so it'll be a one-time leak
anyway, bnad of me to do that
Nish
ps. thanks
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Nish - Native CPian wrote:
so it'll be a one-time leak
I'm not sure. If the code you've posted is in OnDraw, you'll have a leak each time your view is repainted.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|