Discussion:
[LAU] samplerate conversion targetting number of samples
Brent Busby
2018-11-14 01:08:52 UTC
Permalink
Anyone know some Linux CLI tools that would be good to batch convert a
folder of 24/96 samples, mostly small waveform clips about two to four
wavecycles long each, down to 8-bit...<drumroll>...and the nearest
number of samples that's a multiple of 256 by stretching/squeezing, not
by truncation (so as not to ruin looping)?

You can see why I don't want to do this to a large number of files with
a mouse in Audacity... :) Though if you did do it in Audicity, you can
achieve what I'm trying to do by selecting the whole clip, selecting
Effect -> Change Speed from pulldowns, plugging in a new length that's a
multiple of 256 under New Length (with unit set to samples), and
exporting the new file. Except, I really don't want to do that hundreds
of times myself, so a scriptable CLI method would be better.

Basically, I have some Multimoog waveforms that I've sampled with a good
interface, but I'd like to bring them into an Ensoniq Mirage (8-bit),
which likes everything to be on 256-sample page boundaries. I'm hoping
to do some interesting hybrid/wavetable synthesis if I can get the waves
into the machine.

The target samplerate is unimportant, because the Mirage is going to
adjust it up and down itself anyway because of the way its playback
works. Only the length of the clips is important, which should be a
multiple of 256 samples, and it can be downconverted by any amount that
will achieve the length.

Most samplerate conversion seems to target a desired frequency, but I'm
targetting the number of samples, and I'm flexible on whatever
frequency/resolution conversion is needed.
--
- Brent Busby + ===============================================
+ "The introduction of a new kind of music must
-- Studio -- + be shunned as imperiling the whole state, for
-- Amadeus/ -- + styles of music are never disturbed without
-- Keycorner -- + without affecting the most important political
-- Recording -- + institutions." --Plato, "Republic"
----------------+ ===============================================
Jeanette C.
2018-11-14 07:00:11 UTC
Permalink
Post by Brent Busby
Anyone know some Linux CLI tools that would be good to batch convert a
folder of 24/96 samples, mostly small waveform clips about two to four
wavecycles long each, down to 8-bit...<drumroll>...and the nearest
number of samples that's a multiple of 256 by stretching/squeezing, not
by truncation (so as not to ruin looping)?
Hm, not in one go. But sndfile-convert will convert it down to 8-bit.
With sndfile-info you can obtain all kinds of info, including the length
in samples. If you know your way around CLI tools such as grep, awk
and/or sed you can extract the number of samples into a variable. With a
tool like bc you can do the necessary maths, depending on the desired
solution a modulo operation or floating point division.

Now the difficult bit. sndfile-resample offers the samplerate conversion
option -by amount, so you can give a factor. I guess it comes down to
which samplerates wav does support.

Another way could be to use soundstretch to change the speed by the
necessary factor. It works not by FFT, which is fine for small(er)
adjustments.

If you can spot a way, but have insurmountable challanges with the
scripting practicalities, let me know. I'd be happy to help.

Best wishes and good luck,

Jeanette
--
* Website: http://juliencoder.de - for summer is a state of sound
* SoundCloud: https://soundcloud.com/jeanette_c
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
* GitHub: https://github.com/jeanette-c
* Twitter: https://twitter.com/jeanette_c_s

I'm so curious, what do you think of me <3
(Britney Spears)
Lorenzo Sutton
2018-11-14 08:49:44 UTC
Permalink
Post by Brent Busby
Anyone know some Linux CLI tools that would be good to batch convert a
folder of 24/96 samples, mostly small waveform clips about two to four
wavecycles long each, down to 8-bit...<drumroll>...and the nearest
number of samples that's a multiple of 256 by stretching/squeezing, not
by truncation (so as not to ruin looping)?
Maybe a mix of soxi and sox [1] with the speed effect?

Lorenzo.

[1] http://sox.sourceforge.net/sox.html

Loading...