|
Ok...perhaps you could post the code here? Otherwise we cannot offer an explanation of it.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Cool, didnt get an email notifying me of a response.. sorry it took so long.
Heres the code. Its from a Microsoft sample app for creating a voice font, for SAPI.
/******************************************************************************
* mkvoice.cpp *
*-------------*
* This application assembles a simple voice font for the sample TTS engine.
*Copyright (c) Microsoft Corporation. All rights reserved.
*
******************************************************************************/
#include "stdafx.h"
#include <ttseng_i.c>
#include <direct.h>
int wmain(int argc, WCHAR* argv[])
{
USES_CONVERSION;
static const DWORD dwVersion = { 1 };
ULONG ulNumWords = 0;
HRESULT hr = S_OK;
//--- Check args
if( argc != 4 )
{
printf( "%s", "Usage: > mkvoice [[in]word list file] [[out]voice file] [voice name]\n" );
hr = E_INVALIDARG;
}
else
{
::CoInitialize( NULL );
//--- Open word list file and create output voice file
//--- _wfopen is not supported on Win9x, so use fopen.
FILE* hWordList = fopen( W2A(argv[1]), "r" );
FILE* hVoiceFile = fopen( W2A(argv[2]), "wb" );
if( hWordList && hVoiceFile )
{
//--- Write file version and leave space for word count
if( !fwrite( &dwVersion, sizeof(dwVersion), 1, hVoiceFile ) ||
fseek( hVoiceFile, 4, SEEK_CUR ) )
{
hr = E_FAIL;
}
//--- Get each entry
WCHAR WordFileName[MAX_PATH];
while( SUCCEEDED( hr ) && fgetws( WordFileName, MAX_PATH, hWordList ) )
{
ULONG ulTextLen = wcslen( WordFileName );
if( WordFileName[ulTextLen-1] == '\n' )
{
WordFileName[--ulTextLen] = NULL;
}
//--- Include NULL character when writing to the file
ulTextLen = (ulTextLen+1) * sizeof(WCHAR);
if( fwrite( &ulTextLen, sizeof(ulTextLen), 1, hVoiceFile ) &&
fwrite( WordFileName, ulTextLen, 1, hVoiceFile ) )
{
++ulNumWords;
//--- Open the wav data
ISpStream* pStream;
wcscat( WordFileName, L".wav" );
hr = SPBindToFile( WordFileName, SPFM_OPEN_READONLY, &pStream );
if( SUCCEEDED( hr ) )
{
CSpStreamFormat Fmt;
Fmt.AssignFormat(pStream);
if( Fmt.ComputeFormatEnum() == SPSF_11kHz16BitMono )
{
STATSTG Stat;
hr = pStream->Stat( &Stat, STATFLAG_NONAME );
ULONG ulNumBytes = Stat.cbSize.LowPart;
//--- Write the number of audio bytes
if( SUCCEEDED( hr ) &&
fwrite( &ulNumBytes, sizeof(ulNumBytes), 1, hVoiceFile ) )
{
BYTE* Buff = (BYTE*)alloca( ulNumBytes );
if( SUCCEEDED( hr = pStream->Read( Buff, ulNumBytes, NULL ) ) )
{
//--- Write the audio samples
if( !fwrite( Buff, 1, ulNumBytes, hVoiceFile ) )
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}
}
else
{
printf( "Input file: %s has wrong wav format.", WordFileName );
}
pStream->Release();
}
}
else
{
hr = E_FAIL;
}
}
}
else
{
hr = E_FAIL;
}
//--- Write word count
if( SUCCEEDED( hr ) )
{
if( fseek( hVoiceFile, sizeof(dwVersion), SEEK_SET ) ||
!fwrite( &ulNumWords, sizeof(ulNumWords), 1, hVoiceFile ) )
{
hr = E_FAIL;
}
}
//--- Register the new voice file
// The section below shows how to programatically create a token for
// the new voice and set its attributes.
if( SUCCEEDED( hr ) )
{
CComPtr<ispobjecttoken> cpToken;
CComPtr<ispdatakey> cpDataKeyAttribs;
hr = SpCreateNewTokenEx(
SPCAT_VOICES,
argv[3],
&CLSID_SampleTTSEngine,
L"Sample TTS Voice",
0x409,
L"Sample TTS Voice",
&cpToken,
&cpDataKeyAttribs);
//--- Set additional attributes for searching and the path to the
// voice data file we just created.
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Gender", L"Male");
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Name", L"SampleTTSVoice");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Language", L"409");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Age", L"Adult");
}
if (SUCCEEDED(hr))
{
hr = cpDataKeyAttribs->SetStringValue(L"Vendor", L"Microsoft");
}
//--- _wfullpath is not supported on Win9x, so use _fullpath.
CHAR szFullPath[MAX_PATH * 2];
if (SUCCEEDED(hr) && _fullpath(szFullPath, W2A(argv[2]), sizeof(szFullPath)/sizeof(szFullPath[0])) == NULL)
{
hr = SPERR_NOT_FOUND;
}
if (SUCCEEDED(hr))
{
USES_CONVERSION;
hr = cpToken->SetStringValue(L"VoiceData", A2W(szFullPath));
}
}
}
//--- Cleanup
if( hWordList )
{
fclose( hWordList );
}
if( hVoiceFile )
{
fclose( hVoiceFile );
}
::CoUninitialize();
}
return FAILED( hr );
}
|
|
|
|
|
if you want to learn C++, don't use this example !!!!
start with the basics, then start learnin at some libraries (Win32, MFC, ATL, ...), and only then, you could read some advanced examples like that.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I don't want to learn C++. I was simply asking if someone could point me in the right direction here as to what exactly this code is doing.
|
|
|
|
|
Basically i just want to change those five or six cpDataKeyAttribs...
Maybe I should just compile it, know any free C++ compilers?
|
|
|
|
|
search for gcc and g++ (linux based, but maybe ported to windows plateforms)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
If I say
this.CreateGraphics();
What's "this"?
|
|
|
|
|
"this" is a key word to refer to the currently instantiated class that the method is in so if you had:
<br />
public ref class FrmMyCoolForm : public System::Windows::Forms::Form<br />
{<br />
public:<br />
FrmMyCoolForm(void)<br />
{<br />
this->Visible = false;<br />
}<br />
}<br />
You would be changing the visiblility of the object that the method was called from.
(Probably not close to a textbook definition but hope it makes sense)
EDIT: Here is a definition C++ keyword used in a member function to point at the object currently being operated on.
|
|
|
|
|
THanks- I inderstad that. I'm referring to the CreateGraphics.
CreateGraphics is a "method" when a WHAT is instantiate.
int x;
this->Foo() == x.Foo() //OK
this.CreateGraphics() // What's "this"? in THIS case
Is it Graphics g?
|
|
|
|
|
|
Hi,
I want to save and open a file in Win32,example I want store a array or matrix in a file in Win32.Please help me.
Thanks.
|
|
|
|
|
Hi!
You can use Win32 API:
for example:
DWORD ByteWriten , ByteRead;
int MyArray[5] = {2534 ,3535, 3534,4576,54};
int ReadArray[5];
HANDLE MyHand =
CreateFile("c:\\sampfile" , GENERIC_WRITE | GENERIC_READ , FILE_SHARE_READ | FILE_SHARE_WRITE ,
NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL); //Create Handle To File
WriteFile(MyHand , (void *)MyArray , 10/* 5*2(int) */ , &ByteWriten , NULL);
//Write Array to file
ReadFile(MyHand , (void *)ReadArray , 10 , &ByteRead , NULL);
//Read Array From file.
CloseHandle(MyHand);
CRTE_Tech
|
|
|
|
|
insertion and deletion using linear linked list
|
|
|
|
|
Anonymous wrote:
insertion and deletion using linear linked list
Good, you working on it?
-prakash
|
|
|
|
|
hello
: i am pursuing A Level From DOEACC in india.
: i wanted a Project in c++ relating following topics or something new like planets, solar eclipse etc, Or library management or bank management or railway reservation which includes any of the topics like class, inheritance, file handling,arrays.
: or if anyone can suggest a project program related to the above topics(games, etc.).
: i would be grateful to u if u reply.
: can u tell me a site which has these type of programs.
:
: thanks
: gagit
|
|
|
|
|
|
Can anyone please tell me why this code code gives a segmentation? The
class NonLeafTrieNode<br />
{<br />
public:<br />
NonLeafTrieNode(){};<br />
NonLeafTrieNode(char);<br />
<br />
private:<br />
friend class Trie;<br />
<br />
NonLeafTrieNode **ptrs;<br />
char *letters;<br />
int endOfWord;<br />
bool isLeaf;<br />
};
The code below are in the Trie class and I use this to access the isLeaf variable in the class.
int flag = p->ptrs[pos]->isLeaf;<br />
if (!(pos == -1) && flag)
If I keep the isLeaf variable a boolean the code gives a segmentation fault, but whenever I make it a integer the code works perfectly.
Can anyone tell me why this happens.
Thanks a lot
LiquidE_SA
|
|
|
|
|
A very strange bug; sounds to me like some kind of memory access splat. There's not too much to go on from your example, but the fact you're using an array (ptrs[]) and that changing the size of the class (by changing bool to int [see note]) causes a crash, sounds to me like something somewhere isn't accessing the right memory.
Ensure you've allocated enough memory for ptrs[] and that 'pos' is in within a valid range - if that doesn' solve it perhaps post a bit more information - whereabouts is the crash? I assume it's on the 'p->ptrs[pos]->isLeaf' line.
Matt Godbolt
Engineer, ProFactor Software
StyleManager project
|
|
|
|
|
|
I have one function with 3 parameters.
In that function I have one switch case statement which depends on first parameter of my function. Nearly the cases are 28 to 30. For each case there is another sub switch case which depends on the second parameter of my function with more cases. For different cases I am allocating different classes memory in one class object. At last the function returning that object. For this concept implementation is there any simple implementation or any other logic, any template. The cases are increasing because of new implementations. Expecting some better solution.
The sample code is:
CMyCls* CEmr:GetCls(DWORD dwDId, DWORD dwClsId,BOOL bFe)
{
CMyCls* pCls = NULL;
switch (m_byClsFamily)
{
case _FAMILY_1_:
switch (dwClsId)
{
case 0x8242:
if (bFe || (dwDId == DB_18C453))
pCls = new CMyCls1;
break;
case 0x8252:
if (bFe || (dwDId == DB_18C452))
pCls = new CMyCls2;
break;
...
...
}
break;
case _FAMILY_2_:
...
case _FAMILY_3_:
...
case _FAMILY_4_:
...
...
break;
}
return pCls;
}
Here All CMyCls1, CMyCls2, CMyCls3, CMyCls4,... all are derived from a class named "CMyCls".
My actual problem is, I need to simplify my switch case. I am searching for the easyest way even the cases may be increased in near future. In different case I need to create different Calss's object. Creating object is not a problem. But the switch case becomeing very big. I am looking for any good template or any other solution.
Any help very thankful to them. It is urgent.
Nice talking to you.
|
|
|
|
|
Hi, everybody!
I am trying to build a numerical simulation which stores data in a mat-file. My program was written by C++ and runs on Linux. I want to store output data in mat-file because it's convenient to analyze in matlab. I don't know how to write the data to a mat-file and how to buid a C++ program integrated with matlab in Linux.
Please help me.
Thanks a lot!
h
|
|
|
|
|
Hello, guys!
I'm not found at the WEB any good link with example of implementation of DirectShow's DVD seeking. How I can correctly perform DVD (also VOB files) seeking with Direct Show Interface?
Thanks.
|
|
|
|
|
I m not getting how to run music or .bmp files in c++. I have a bit of idea that a third party tool will be needed in doing that, but I dont know exactly how it is done. Please if any body can sort out this problem.
Inder Gujral
|
|
|
|
|
try createprocess.
-prakash
|
|
|
|
|
This was a very stupid answer.Createprocess will not help at all in linkin the audio driver with compiler.
|
|
|
|
|