Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions rdac2wav/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void convertM24(char *inFileName, char *outFileName, int sampleRate, int bitDept
void convertCDR(char *inFileName, char *outFileName, int sampleRate, int bitDepth);

int isSupportedMode(char *mode);
int isSupportedClusterSize(char *size);
int isSupportedClusterSize(char *size, char *mode);
int isSupportedBitDepth(int bitDepth);
long fsize(const char *const name);

Expand Down Expand Up @@ -84,7 +84,7 @@ int main(int argc, char **argv)
outFileName == NULL || strlen(outFileName) == 0 ||
!isSupportedBitDepth(bitDepth) ||
!isSupportedMode(rdacMode) ||
!isSupportedClusterSize(clusterSize)) {
!isSupportedClusterSize(clusterSize, rdacMode)) {

printf("\n");
printf("**********************************************************\n");
Expand Down Expand Up @@ -306,12 +306,17 @@ void convertMT2(char *inFileName, char *outFileName, int sampleRate, int bitDept
pageSize = 65536;
blocksPerPage = 5460;
}
else if (stricmp(clusterSize,"16k") == 0) {
pageSize = 16384;
blocksPerPage = 1365;
}

int pagePadBytes = pageSize - blocksPerPage*12;
int numPages = ((int)fileSize)/pageSize;
int leftOverBytes = ((int)fileSize)%pageSize;
int numBlocks = numPages*blocksPerPage + leftOverBytes/12;


// Write the WAV header
int numSamples = numBlocks*16;
writeWavHeader(fout, numSamples, sampleRate, bitDepth, 1);
Expand Down Expand Up @@ -517,8 +522,9 @@ int isSupportedMode(char *mode)
return 0;
}
//*****************************************************************************
int isSupportedClusterSize(char *size)
int isSupportedClusterSize(char *size, char *mode)
{
if ((stricmp(size, "16k") == 0) && (stricmp(mode, "mt2") == 0) ) return 1;
if (stricmp(size, "32k") == 0) return 1;
if (stricmp(size, "64k") == 0) return 1;
return 0;
Expand Down