In Debian we can do the following to get libsndfile dll.
1. apt-get source libsndfile
- 2. ./configure --disable-sqlite --disable-external-libs --host 'i586-mingw32msvc'; make
+ 2. ./configure --disable-sqlite --disable-external-libs --host 'i686-w64-mingw32'; make
3. libsndfile-1.dll will be at src/.libs/
Now we start build wavtool-pl.
- 1. ./configure --host 'i586-mingw32msvc' SNDFILE_LIBS="-L/tmp/libsndfile-*/src/.libs -lsndfile-1" SNDFILE_CFLAGS="-I/tmp/libsndfile-*/src/"
+ 1. ./configure --host 'i686-w64-mingw32' SNDFILE_LIBS="-L/tmp/libsndfile-*/src/.libs -lsndfile-1" SNDFILE_CFLAGS="-I/tmp/libsndfile-*/src/"
2. make
3. wavtool-pl.exe will be at src/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <sndfile.h>
* @param b sample B
* @return sample of A mix B
*/
-short wfd_mix(short a, short b) {
+int16_t wfd_mix(int16_t a, int16_t b) {
int a_t;
int b_t;
int r1;
- short ret=0.0;
+ int16_t ret=0;
a_t = ((int)a)+32768;
b_t = ((int)b)+32768;
}
}
r1 = r1 - 32768;
- ret = ((short)r1);
+ ret = ((int16_t)r1);
return ret;
}
FILE *outfile=NULL;
SNDFILE *inputfile=NULL;
SF_INFO inputfileinfo;
- short *buf=NULL;
+ int16_t *buf=NULL;
int p_f[7];
double v_f[7];
int currentFrame=0;
int ovrFrames=0;
int outputFrames=0;
int i;
- short sum;
+ int16_t sum;
int c1,c2;
memset(&inputfileinfo,0,sizeof(SF_INFO));
- outfile = fopen(outputfilename,"r+");
+ outfile = fopen(outputfilename,"r+b");
fseek(outfile,0,SEEK_END);
if (inputfilename) {
inputfile = sf_open(inputfilename,SFM_READ,&inputfileinfo);
}
}
}
+ fflush(outfile);
fseek(outfile,0,SEEK_CUR);
ovr=0.0;
ovrFrames=0;
}
/* output */
- buf = (short *)malloc(sizeof(short)*(inputfileinfo.channels));
- memset(buf,0,sizeof(short)*(inputfileinfo.channels));
+ buf = (int16_t *)malloc(sizeof(int16_t)*(inputfileinfo.channels));
+ memset(buf,0,sizeof(int16_t)*(inputfileinfo.channels));
currentFrame = 0;
for ( ; outputFrames > 0; outputFrames--) {
if (inputfile) {
int result1;
- result1 = sf_readf_short(inputfile,buf,1);
+ result1 = (int)sf_readf_short(inputfile,buf,1);
if (result1 < 1) {
- memset(buf,0,sizeof(short)*(inputfileinfo.channels));
+ memset(buf,0,sizeof(int16_t)*(inputfileinfo.channels));
sf_close(inputfile);
inputfile=NULL;
}
double vf;
sum = sum/inputfileinfo.channels;
vf = wfd_append_linear_volume(currentFrame,p_f,v_f);
- sum = (short)(((double)sum)*(vf/100.0));
+ sum = (int16_t)(((double)sum)*(vf/100.0));
} else {
sum=0;
}
if (ovrFrames>0) {
- short d,r;
+ int16_t d,r;
c1 = fgetc(outfile);
if (c1 == EOF) {
ovrFrames=0;
fseek(outfile,-2,SEEK_CUR);
d = (c1 & (0x00ff)) | (((c2 & 0x00ff) << 8) & 0xff00);
r = wfd_mix(sum,d);
- fputc( (char)(r & (0x00ff)), outfile);
- fputc( (char)((r>>8) & 0x00ff), outfile);
+ fputc( (int)((r) & (0x00ff)), outfile);
+ fputc( (int)((r>>8) & 0x00ff), outfile);
+ fflush(outfile);
fseek(outfile,0,SEEK_CUR);
ovrFrames--;
} else {
wfd_append_normal:
- fputc( (char)(sum & (0x00ff)), outfile);
- fputc( (char)((sum>>8) & 0x00ff), outfile);
+ fputc( (int)((sum) & (0x00ff)), outfile);
+ fputc( (int)((sum>>8) & 0x00ff), outfile);
+ fflush(outfile);
fseek(outfile,0,SEEK_CUR);
}
currentFrame++;
}
ret = ret + (int)((c & 0x00ff)*(0x01<<(8*i)));
}
+ fseek(file1,0,SEEK_CUR);
return ret;
}
d = d/256;
fputc(w,file1);
}
+ fflush(file1);
+ fseek(file1,0,SEEK_CUR);
}
/**
*/
void wfh_init(const char *filename) {
FILE *file1=NULL;
- file1 = fopen(filename,"w");
+ file1 = fopen(filename,"wb");
if (!file1) {
return;
}
int ret=-1;
char com1[100];
int s;
- file1=fopen(filename,"r");
+ file1=fopen(filename,"rb");
if (!file1) {
return ret;
}
int ret=-1;
char com1[100];
int s;
- file1=fopen(filename,"r+");
+ file1=fopen(filename,"r+b");
if (!file1) {
return ret;
}