- fixed wav
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/wav@987 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -14,9 +14,8 @@
|
||||
/******************************************************************************/
|
||||
/* C definitions
|
||||
/******************************************************************************/
|
||||
void WavInit(struct _sWAV *pObj, uint32_t nSamplesPerSec, uint16_t nBits, uint16_t nChannels, uint16_t format)
|
||||
void WavInit(struct _sWAV *pObj)
|
||||
{
|
||||
WavSetFormat(pObj, nSamplesPerSec, nBits, nChannels, format);
|
||||
pObj->m_FileType = FILETYPE_RAW;
|
||||
pObj->m_FileSize = 0;
|
||||
pObj->m_HeaderSize = 0;
|
||||
@@ -43,9 +42,21 @@ uint32_t WavSetFormat(struct _sWAV *pObj, uint32_t nSamplesPerSec, uint16_t nBit
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t WavSetHeader(struct _sWAV *pObj, const WAVEHEADER *pHeader)
|
||||
{
|
||||
memcpy(&pObj->m_Format, pHeader, sizeof(WAVEHEADER));
|
||||
|
||||
pObj->m_nChannels = pObj->m_Format.nChannels;
|
||||
pObj->m_SampleRate = pObj->m_Format.nSamplesPerSec;
|
||||
pObj->m_nBits = pObj->m_Format.wBitsPerSample;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
uint32_t WavOpen (struct _sWAV *pObj, const char* FileName)
|
||||
{
|
||||
WavInit(pObj);
|
||||
uint32_t stat;
|
||||
|
||||
//Wav-File �ffnen
|
||||
@@ -82,13 +93,17 @@ uint32_t WavClose(struct _sWAV *pObj)
|
||||
if (!pObj->WREAD && (pObj->m_FileType == FILETYPE_WAV))
|
||||
WriteHeader(pObj);
|
||||
|
||||
fclose(pObj->pHndWavFile);
|
||||
if (pObj->pHndWavFile)
|
||||
{
|
||||
fclose(pObj->pHndWavFile);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
uint32_t WavCreate (struct _sWAV *pObj, char *fileName, uint32_t fileType)
|
||||
uint32_t WavCreate (struct _sWAV *pObj, const char *fileName, uint32_t fileType, const WAVEHEADER *pHeader)
|
||||
{
|
||||
WavInit(pObj);
|
||||
pObj->m_FileType = fileType;
|
||||
|
||||
strcpy(pObj->m_Name, fileName);
|
||||
@@ -100,7 +115,13 @@ uint32_t WavCreate (struct _sWAV *pObj, char *fileName, uint32_t fileType)
|
||||
|
||||
pObj->WREAD = 0;
|
||||
if (pObj->m_FileType == FILETYPE_WAV)
|
||||
WriteHeader(pObj);
|
||||
{
|
||||
if (pHeader)
|
||||
{
|
||||
WavSetHeader(pObj, pHeader);
|
||||
}
|
||||
WriteHeader(pObj);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,11 @@ typedef struct _sWAV
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void WavInit(struct _sWAV*, uint32_t nSamplesPerSec, uint16_t nBits, uint16_t nChannels, uint16_t format);
|
||||
void WavInit(struct _sWAV*);
|
||||
uint32_t WavSetFormat(struct _sWAV*, uint32_t, uint16_t, uint16_t, uint16_t format);
|
||||
uint32_t WavSetHeader(struct _sWAV *pObj, const WAVEHEADER *pHeader);
|
||||
uint32_t WavOpen (struct _sWAV*, const char*);
|
||||
uint32_t WavCreate(struct _sWAV*, char*, uint32_t);
|
||||
uint32_t WavCreate(struct _sWAV*, const char*, uint32_t, const WAVEHEADER *pHeader);
|
||||
uint32_t WavClose(struct _sWAV*);
|
||||
uint32_t WavRead(struct _sWAV*, void*, uint32_t);
|
||||
uint32_t WavWrite(struct _sWAV*, void*, uint32_t);
|
||||
|
||||
Reference in New Issue
Block a user