sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* Help with fractions re: resampling
@ 2015-01-06 21:58 Christopher Paul Kalafarski
  2015-01-07  6:37 ` Erich Eckner
  2015-01-08  6:28 ` Rob Sykes
  0 siblings, 2 replies; 4+ messages in thread
From: Christopher Paul Kalafarski @ 2015-01-06 21:58 UTC (permalink / raw)
  To: sox-users

I’m really struggling with what I thought would be relatively simple process of reading a file (with libsndfile), resampling it (using soxr), and writing it back to disk (with sndfile again). I realize this list is for neither of those libraries, but afaik soxr is extracted from SoX just with a different API, and I think my issue is in dealing with the resulting data, and not the API.

My main confusion is that if I pass in, e.g., 4096 frames at 48000, and resample to 44100, mathematically I would expect to get back 3763.2 frames. What is the proper way to handle the 0.2 frames in this case? Does the library handle that transparently? Or should I be doing some amount of math to figure out leap-frames every few cycles? No examples I’ve seen explicitly handle this, so I’m guessing it’s unnecessary, but I’m running out of other avenues to try to fix the problem I’m having, so I’ve kind of gone back to basics.

Thanks for any help.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with fractions re: resampling
  2015-01-06 21:58 Help with fractions re: resampling Christopher Paul Kalafarski
@ 2015-01-07  6:37 ` Erich Eckner
  2015-01-07 14:37   ` Christopher Paul Kalafarski
  2015-01-08  6:28 ` Rob Sykes
  1 sibling, 1 reply; 4+ messages in thread
From: Erich Eckner @ 2015-01-07  6:37 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1916 bytes --]

Hi,

first: I don't know the sox source code, so I have no Idea, what
sox/soxr really does, but:

Why don't you give it a different amount of frames, like 4800? So you
would get 4410 frames back and everything is fine.

greetings,
Erich

Am 06.01.2015 22:58, schrieb Christopher Paul Kalafarski:
> I’m really struggling with what I thought would be relatively simple process of reading a file (with libsndfile), resampling it (using soxr), and writing it back to disk (with sndfile again). I realize this list is for neither of those libraries, but afaik soxr is extracted from SoX just with a different API, and I think my issue is in dealing with the resulting data, and not the API.
> 
> My main confusion is that if I pass in, e.g., 4096 frames at 48000, and resample to 44100, mathematically I would expect to get back 3763.2 frames. What is the proper way to handle the 0.2 frames in this case? Does the library handle that transparently? Or should I be doing some amount of math to figure out leap-frames every few cycles? No examples I’ve seen explicitly handle this, so I’m guessing it’s unnecessary, but I’m running out of other avenues to try to fix the problem I’m having, so I’ve kind of gone back to basics.
> 
> Thanks for any help.
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
> 



[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 834 bytes --]

[-- Attachment #2: Type: text/plain, Size: 440 bytes --]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with fractions re: resampling
  2015-01-07  6:37 ` Erich Eckner
@ 2015-01-07 14:37   ` Christopher Paul Kalafarski
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Paul Kalafarski @ 2015-01-07 14:37 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 3096 bytes --]

Thanks for the idea. Certainly made the math easier, but I’m still having the original issue where the resampled audio is stuttering. The IO seems to be fine, because if I skip the resample, the output file matches the input file. I’m not sure how else to change how I’m configuring or executing the resample process; it seems fairly straightforward, and some of the data is getting through so I must have mismatch somewhere.


> On Jan 7, 2015, at 01:37, Erich Eckner <erich@eckner.net> wrote:
> 
> Hi,
> 
> first: I don't know the sox source code, so I have no Idea, what
> sox/soxr really does, but:
> 
> Why don't you give it a different amount of frames, like 4800? So you
> would get 4410 frames back and everything is fine.
> 
> greetings,
> Erich
> 
> Am 06.01.2015 22:58, schrieb Christopher Paul Kalafarski:
>> I’m really struggling with what I thought would be relatively simple process of reading a file (with libsndfile), resampling it (using soxr), and writing it back to disk (with sndfile again). I realize this list is for neither of those libraries, but afaik soxr is extracted from SoX just with a different API, and I think my issue is in dealing with the resulting data, and not the API.
>> 
>> My main confusion is that if I pass in, e.g., 4096 frames at 48000, and resample to 44100, mathematically I would expect to get back 3763.2 frames. What is the proper way to handle the 0.2 frames in this case? Does the library handle that transparently? Or should I be doing some amount of math to figure out leap-frames every few cycles? No examples I’ve seen explicitly handle this, so I’m guessing it’s unnecessary, but I’m running out of other avenues to try to fix the problem I’m having, so I’ve kind of gone back to basics.
>> 
>> Thanks for any help.
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming! The Go Parallel Website,
>> sponsored by Intel and developed in partnership with Slashdot Media, is your
>> hub for all things parallel software development, from weekly thought
>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>> look and join the conversation now. http://goparallel.sourceforge.net
>> _______________________________________________
>> Sox-users mailing list
>> Sox-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/sox-users
>> 
> 
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net_______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users


[-- Attachment #1.2.1: Type: text/html, Size: 4461 bytes --]

[-- Attachment #1.2.2: Screen-Shot-2015-01-07-at-09.25.29-(1).jpeg --]
[-- Type: image/jpeg, Size: 15881 bytes --]

[-- Attachment #2: Type: text/plain, Size: 440 bytes --]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with fractions re: resampling
  2015-01-06 21:58 Help with fractions re: resampling Christopher Paul Kalafarski
  2015-01-07  6:37 ` Erich Eckner
@ 2015-01-08  6:28 ` Rob Sykes
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Sykes @ 2015-01-08  6:28 UTC (permalink / raw)
  To: sox-users@lists.sourceforge.net


[-- Attachment #1.1: Type: text/plain, Size: 1364 bytes --]

 

     On Tuesday, 6 January 2015, 22:18, Christopher Paul Kalafarski <chris@farski.com> wrote:
   
 

 I’m really struggling with what I thought would be relatively simple process of reading a file (with libsndfile), resampling it (using soxr), and writing it back to disk (with sndfile again). I realize this list is for neither of those libraries, but afaik soxr is extracted from SoX just with a different API, and I think my issue is in dealing with the resulting data, and not the API.

My main confusion is that if I pass in, e.g., 4096 frames at 48000, and resample to 44100, mathematically I would expect to get back 3763.2 frames. What is the proper way to handle the 0.2 frames in this case?
Conceptually, the 0.2 is buffered within the resampler, so consecutive inputs of 4096 could result in 3763, 3763, 3763, 3763, 3764, 3763, ... being output. In practice though, there can be a lot more variation in the output pattern, due to internal buffering and block processing.  For this reason, it often makes sense for resampling to be output driven. E.g., if every 10ms, you need to present 441 samples to your output hardware, then every 10ms, resample as much input data as is needed to get (at least) 441 samples needed for the output. soxr supports this paradigm via the soxr_set_input_fn() and soxr_output() functions.  HTH.   

[-- Attachment #1.2: Type: text/html, Size: 2780 bytes --]

[-- Attachment #2: Type: text/plain, Size: 440 bytes --]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net

[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-08  6:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-06 21:58 Help with fractions re: resampling Christopher Paul Kalafarski
2015-01-07  6:37 ` Erich Eckner
2015-01-07 14:37   ` Christopher Paul Kalafarski
2015-01-08  6:28 ` Rob Sykes

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).