Index: apps/plugins/mp3_encoder.c =================================================================== --- apps/plugins/mp3_encoder.c (revision 28960) +++ apps/plugins/mp3_encoder.c (working copy) @@ -881,6 +881,8 @@ wBlockAlign = Read16BitsLowHigh(wavfile); bits_per_samp = Read16BitsLowHigh(wavfile); + rb->splashf (HZ * 1, "(1) channels %d, rate %d", cfg.channels, cfg.samplerate); + if(wFormatTag != 0x0001) return -5; if(bits_per_samp != 16) return -6; if(cfg.channels > 2) return -7; @@ -893,13 +895,26 @@ return 0; } -int read_samples(uint32_t *buffer, int num_samples) +int read_samples(uint16_t *buffer, int num_samples) { - int s, samples = rb->read(wavfile, buffer, 4 * num_samples) / 4; + uint16_t tmpbuf[SAMP_PER_FRAME*2]; /* SAMP_PER_FRAME*MAX_CHANNELS */ + int byte_per_sample = cfg.channels * 2; /* requires bits_per_sample==16 */ + int s, samples = rb->read(wavfile, tmpbuf, byte_per_sample * num_samples) / byte_per_sample; /* Pad last sample with zeros */ - for(s=samples; s> 1); } - if(cfg.channels == 1) /* mix left and right channels to mono */ - for(i=2*512; i<2*512+2*SAMP_PER_FRAME; i+=2) - mfbuf[i] = mfbuf[i+1] = (short)(((int)mfbuf[i] + mfbuf[i+1]) >> 1); +//AB if(cfg.channels == 1) /* mix left and right channels to mono */ +//AB for(i=2*512; i<2*512+2*SAMP_PER_FRAME; i+=2) +//AB mfbuf[i] = mfbuf[i+1] = (short)(((int)mfbuf[i] + mfbuf[i+1]) >> 1); cfg.ResvSize = 0; gr_cnt = cfg.granules * cfg.channels; @@ -2560,7 +2575,7 @@ ret = wave_open(); if(ret == 0) { - init_mp3_encoder_engine(true, brate[srat], cfg.samplerate); + init_mp3_encoder_engine((cfg.channels==2), brate[srat], cfg.samplerate); get_mp3_filename(wav_filename); mp3file = rb->open(mp3_name , O_WRONLY|O_CREAT|O_TRUNC, 0666); frames = 0;