Resample causing data loss

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Resample causing data loss

Christopher Kalafarski
I’m using SoX (actually libsoxr, but I haven’t gotten a response on that mailing list, so I’m hoping someone here can help) to resample some audio files. I’d like to keep the dependencies of the library I’m making as low as possible, which is why I’m using soxr over sox; doing so means I need to handle the file IO myself, and I’m not particularly familiar with these particular aspects of C. (Also at this point I’m just frustrated I can’t figure this out, so I’d like to solve the mystery)

Basically what I’m doing is taking the input file, detecting the format, handing it to soxr, and then writing the result to a new file. I’m using libsndfile to read and write, and if I short circuit the resampling step the output file is correct (i.e. I think the reading and writing is working fine).

The problem I’m having when I introduce the resampling is that the I’m not getting back as many frames as I should. For instance when converting from 48 to 44.1, I would expect to get back 3763 frames (I’m reading in 4096 frames), but I’m only actually getting ~2900. This is obviously making the resulting audio unusable.

As I said, I’m a little out of my depth here, but it seems like the problem is definitely with the resampling step, and I’ve triple checked how I’m setting up the processor and reread the examples and API, and I’m just not seeing anything obvious that could cause this.

My code for entire read-resample-write process is here:

If anyone could help me out I’d really appreciate it
Thanks


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Resample causing data loss

Pascal Giard

Le 2014-11-21 à 10:28, Christopher Kalafarski <[hidden email]> a écrit :


The problem I’m having when I introduce the resampling is that the I’m not getting back as many frames as I should. For instance when converting from 48 to 44.1, I would expect to get back 3763 frames (I’m reading in 4096 frames), but I’m only actually getting ~2900. This is obviously making the resulting audio unusable.

Since you are using soxr, perhaps your problem is related to the last FAQ entry:

It seems to describe what you are experiencing.

-Pascal

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users