I've been playing around a bit with pd audio objects mostly basic stuff from help files.
I'm just wondering if is possible to emulate 32kHz 12 bit sampler sound in pd?
Where to start?
thanks in advance
-
12 bit sampler sound emulation?
-
Thanks Sebfumaster i wish i could understand it all
All i have so far is what Malestorm suggested + samphold
Please see attached patch
My question is whats gonna happen if i pass through it 16 bit 44000 sample ?
is it gonna be converted to 12 bit 32000?It sort of change the sound and add that "his" to the sound similar to my old akai s1000
-
the bitcrushing is right and you are getting the signal to 12 bit, but the resampling is generating aliasing. it is pretty complex. Currently you are taking it down to 32000 but that itself is sampled at 44100
but aliasing can sound good and/or desirable, it depends on the sound you're going for.i forgot to mention that i wouldn't use lop~ for resampling, I'm no dsp expert but just guessing It'd be better to use something like lp4_butt~ from iemlib. basically you don't want any frequencies above 16000 before going into the 32000 samphold~ so you actually need the cutoff a little lower than 16000 to compensate for the skirt.
edit: another thing to do if one does not want aliasing would be to run pd at 64000, and read a 44100 sample at 44.1 k with tabread4~, then send it into your slightly-lower-than- 16000 hz lowpass (lp4_butt~?), and then into a samphold~ with a phasor~ at 32000 (and then maybe another 16000 lowpass?). this is probably the easiest way actually
-
here's what I described above to read 44.1 k samples, to make it better you could find better resampling filters so you can raise the cutoff frequency
make sure you're running at 64000you can also play around with the cutoff frequency of the first filter to get various amounts of aliasing
http://www.pdpatchrepo.info/hurleur/samplerate-conversion.pd
-
Many thanks Sebfumaster thats awesome!!
Btw i tried it on long electric piano loop on both 32k and 64k -> sample rate in pd and i couldnt hear the difference -
if you run pd at 32000 then the samphold~ and filters won't do too much and are actually unnecessary. pd and tabread4~ will do the samplerate and your soundcard's dac will do the second of the 2 filters. I suppose I was assuming you would want to run other audio at the same time (that might have frequencies up to 20000 hz)
actually when I play this patch at 32000 the samphold~ stops everything because the phasor is at 32000 and therefore never changes at 32000 sr, not sure how it got past for you.
upon bypassing the samphold~ the filters make it sound really dark at 32000 for me, I think because the tabread4~ is already reading it at 32000 or there is still aliasing after the filter in the 64 k versionedit: been thinking about this, you could actually emulate a sampler at any samplerate with no aliasing while running pd at any samplerate with just the 1 "analog" resampling filter... but aliasing is part of that old digital sound maybe in which case I would go with the patch above at 64 k
if not, maybe someone with knowledge on adcs can suggest a filter...
-
im already very very happy with the results
thanks so much for sharing your knowledge -
Doing this accurately can be rather complicated, depending on the sampler you're trying to emulate. Any transposition of a recorded sample (i.e. the interesting part of what you expect a sampler to do) is effectively a sample rate conversion, and there are many different ways to do this.
Samplers like the Emu SP-1200 and Ensoniq Mirage play back sounds at low sample rates with only sample truncation (zero order hold). This is important, as it leaves in lots of additional high frequency tones (images). You could set the sample rate to 32 kHz, play samples from a table with [tabread~] rather than [tabread4~] (truncation/zero order hold rather than cubic interpolation), then quantize to 8 or 12 bits (and actually some things used μ-law or A-law DACs, which isn't the same as a linear DAC), then apply an amplitude envelope. You can also independently control the effective input sample rate by quantizing the phasor that's reading the sample.
You can't accurately emulate sample rate reduction using [samphold~] while the patch is running at an unrelated sample rate, as the aliased tones generated by [samphold~] will themselves alias. The sample rate must be an integer multiple of the [samphold~] rate. Similarly it's incorrect to reduce bit depth by quantization after the amplitude envelope.
Other machines like the PPG Wave 2.2 and 2.3, Emu Emax, Sequential Circuits Prophet VS, etc. use the same approach but with a higher output sample rate, around 200 kHz to 1 MHz. You can emulate this by oversampling.
Samplers like the Akai S900, Emu Emulator series, Kurzweil K250, Korg DSS-1, Sequential Circuits Prophet 2000, etc. are much different, as they generate a variable playback sample rate by integer division of a high frequency clock (around 6 to 12 MHz). These generate no inharmonic aliasing at all, and this can't by emulated as easily. You could use either a very high sample rate with constrained playback frequencies, or approximate it using something like integrated wavetables. I've made some abstractions ([dphasor~], etc.) to obtain similar (but not identical) results at more modest sample rates.
The Akai S1000 isn't really "lo-fi" but uses an advanced waveform interpolation that's actually better than the one in [tabread4~]. Many other samplers simply used linear interpolation.
I've been planning on writing more about this, as it's a topic that I'm particularly interested in. I'm sorry if it's unclear, but this is just a really brief overview...
-
You could set the sample rate to 32 kHz, play samples from a table with [tabread~] rather than [tabread4~]
the issue with this is that the samples themselves are recorded at 44.1 so in order to emulate the sampling you need to either read between the sample values first with tabread4~ or convert them beforehand. Quantizing the phasor or vline~ before tabread4~ might work to emulate zero-order hold though if pitchshifting, without pitchshift it can be emulated with just tabread4~. Best would probably be to convert to 32 k with soX beforehand to get better resampling than tabread4~
acreil, happen to have that dphasor~ around?
edit: nevermind, found 'em http://puredata.hurleur.com/viewtopic.php?pid=33738 -
this thread is 7 years old but still fascinating, especially acreills rundown of the vintage synths synthesis as im working on an old school wavetable synth with variable sample rate for a while. i still havent found a way to simulate variable sample rate with correct mirror frequencies in PD. the best way to do this now in hardware would be FPGA and an A-Law Dac that is being driven by the fpga with variable speed - i think.
synths like the PPG wave or the microwave sound exactly so cool because the mirror frequencies move with the tuning harmonically - or disharmonically there is a video of an interview with one of the engineers of the prophet vs where he explains that a strange sounding sine from a PPG wave was one of the main inspirations for the prophet vs.
so tuning, sample rate and resolution are essential for the sound of an instrument.does anybody have any clue as to how to simulate the mirror frequencies and variable sample rate in PD?
-
If the artifacts of the downsampler are the problem, here is a possible solution: https://github.com/MikeMorenoDSP/pd-mkmr/blob/master/effects/fx.downsample~-help.pd
Some further reading: https://ccrma.stanford.edu/~dtyeh/papers/yeh07_icmc_sp12.pdf
-
samplingrate reduction and bitdepth reduction will still not give you satisfying results.
the AKAI S-900 and S-950 for example have a variable-samplingrate DA converter and analogfilters - these are the main soundforming parts.
the emulator II still has the SSM filters.
while you can emulate analog filters quite good today, implementing that AKAI type of DAC within a fixed-rate digital enviroment is not so easy.