Re: [PD] change samplerate locally

2009-03-16 Thread Charles Henry
On Sun, Mar 15, 2009 at 2:44 AM, hard off hard@gmail.com wrote:
 to re-create the sound of a dx7 i need to change samplerate from my default
 (44.1khz) to 28khz.
 globally changing pd's samplerate to 28khz has the intended effect, but i
 want to be able to run other patches at 44.1khz while running my dx7 at
 28khz.

One thing that occurs to me is that the quality of the reconstructed
sound has more to do with the interpolator rather than the sample
rate.

The actual output is an analog signal which is obtained by
interpolating samples.  Most audio systems use linear interpolation,
which has characteristic spectral characteristics.  A low-end or
possibly obsolete system may use sample-and-hold rather than
interpolation.

Probably, there's a high-frequency sizzle that you want to emulate
here.  To get that full sound (an analog signal), there's a freq
domain transformation that should work.

It comes from the linear interpolator.  It actually leaves some sound
in the range from 14kHz to 22.05kHz.  To reproduce the effect, you
would fold over frequencies from 5.95kHz to 14 kHz into 14kHz to
22.05kHz.  Then you would apply the spectrum of the interpolator,
which will reduce but not eliminate the high frequencies.

I haven't worked it all out.  That's as far as I got this weekend.

Chuck



 i naively tried adding this construct to the output, but the sound is
 completely wrong:
 (if it doesn't show, the phasor~ is connected to the right inlet of the
 [samplehold~])

 [inlet~]       [phasor~ 28000]
 |  |
 [samplehold~]
 |
 [outlet~]

 i thought about it for a bit, and i understand why that doesn't work, but i
 can't think of another solution.

 is there some way i can 'mimic' 28khz samplerate while running pd at 44.1?
 or even better, is there some way to locally set the samplerate for a
 patch?  i tried messing round with [block~] but i can't make it do what i
 need.

 also, i need to mimic a 12bit DAC~ too.



 ___
 Pd-list@iem.at mailing list
 UNSUBSCRIBE and account-management -
 http://lists.puredata.info/listinfo/pd-list



___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-16 Thread hard off
One thing that occurs to me is that the quality of the reconstructed
sound has more to do with the interpolator rather than the sample
rate.

i have a feeling that because the synth has non-bandlimited oscillators,
that the sample rate itself is pretty important, or more importantly, the
aliasing effect it has is very important.  i think that that reason why
28khz is sounding 'better' than 44.1 is because of more high frequencies
folding back over and thickening the sound up in the low end.

i could be totally wrong, but that's what it sounds like.

44.1khz is 'thin and wimpy', but at 28khz it's a thicker, fuller sound.
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-16 Thread hard off
so if those aliasing effects are going to help, then maybe a big step will
be to ADD aliasing.  there are a couple of suggestions here:

http://www.music.columbia.edu/pipermail/music-dsp/2002-March/047953.html

and here:

http://www.music.columbia.edu/pipermail/music-dsp/2002-March/047966.html

i'll give them a go tomorrow.
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-16 Thread hard off
i had a minor breakthrough.

upsampling my signal path, by using [block~ 64 1 2] has the same effect on
the sound as lowering pd's global sample rate to 22050.

not perfect, and to me it defies logic, but certainly a lot closer to the
28khz sound than the 44.1khz sound was getting.
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-16 Thread Amos Robinson
Hmm. I thought the DX7 was ~57khz, anyway:
http://www.maths.abdn.ac.uk/~bensondj/html/Chowning.html

On Tue, Mar 17, 2009 at 2:35 AM, hard off hard@gmail.com wrote:
 i had a minor breakthrough.

 upsampling my signal path, by using [block~ 64 1 2] has the same effect on
 the sound as lowering pd's global sample rate to 22050.

 not perfect, and to me it defies logic, but certainly a lot closer to the
 28khz sound than the 44.1khz sound was getting.



 ___
 Pd-list@iem.at mailing list
 UNSUBSCRIBE and account-management -
 http://lists.puredata.info/listinfo/pd-list



___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-15 Thread hard off
so, i thought about this more, and realized that 28hz is quite close to
being 2/3 of 44.1

so, it MIGHT be enough to do the following:

for every 3 samples, output the first sample, the second sample, and then
instead of playing the 3rd sample,  repeat the second sample.

so, if my block looks like:  0.597, 0.604, 0.628, 0.651.. then
the output block would be 0.597, 0.604, 0.604, 0.651 ...

i still have no idea how i would do that.
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-15 Thread Martin Peach

hard off wrote:
to re-create the sound of a dx7 i need to change samplerate from my 
default (44.1khz) to 28khz. 
globally changing pd's samplerate to 28khz has the intended effect, but 
i want to be able to run other patches at 44.1khz while running my dx7 
at 28khz.




I think that the sound card decides what sample rates you can use, you 
probably can get 22.5 and 11.25 but not 28.
A clean resampling usually would mean sampling at a common multiple of 
28kHz and 44.1kHz and then downsampling again, not really feasible with Pd.


i naively tried adding this construct to the output, but the sound is 
completely wrong:
(if it doesn't show, the phasor~ is connected to the right inlet of the 
[samplehold~])


[inlet~]   [phasor~ 28000]
|  |
[samplehold~]
|
[outlet~]

i thought about it for a bit, and i understand why that doesn't work, 
but i can't think of another solution.


is there some way i can 'mimic' 28khz samplerate while running pd at 
44.1?  or even better, is there some way to locally set the samplerate 
for a patch?  i tried messing round with [block~] but i can't make it do 
what i need.





Unless you're looking for aliasing artifacts, wouldn't it be easier to 
use a multi-pole low-pass filter at around 14kHz?



also, i need to mimic a 12bit DAC~ too.


For that you could multiply the samples by 2048 (for bipolar signal) and 
then divide them modulo 2048, like this:

[*~ 2048]
|
[expr~ $v1%2048]
|
[/~ 2048]
|
[dac~]

Martin

___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-15 Thread hard off
hi martin, thanks for taking the time to reply.

i can set pd to whatever samplerate i want in media-audio settings.  i just
checked again going through a whole bunch of values between 22050 and 44100
and they all work.

my problem is that the samplerate is global, and i need it only to be
local.  i think the 'solution' i suggested in my 2nd post is going to be the
way to do it, but i just don't know how to do that.


[*~ 2048]
 |
 [expr~ $v1%2048]
 |
 [/~ 2048]


thanks.  that's what i had done originally, but i couldn't hear any effect.
i guess if i really want 12-bit sound in pd, i'd have to use that construct
after each and every calculation in the signal chain. seems a fair bit of
overkill just to make the sound WORSE though!
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-15 Thread hard off
actually, i just checked and that method i suggested before doesn't work at
all.  it's the same as the [phasor~ 28000] - [samphold~] effect.



martin, i missed this part of your mail before:

Unless you're looking for aliasing artifacts, wouldn't it be easier to use
a multi-pole low-pass filter at around 14kHz?

i just tried that, and i guess what i need must be the aliasing artifacts.
___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list


Re: [PD] change samplerate locally

2009-03-15 Thread Martin Peach

hard off wrote:

hi martin, thanks for taking the time to reply.

i can set pd to whatever samplerate i want in media-audio settings.  i 
just checked again going through a whole bunch of values between 22050 
and 44100 and they all work.


Yes you're right. I should have checked first ;)
Maybe writing into a table at 44100 and using [tabread4~] with a signal 
that is quantized to the ratio of sample rates would work?




my problem is that the samplerate is global, and i need it only to be 
local.  i think the 'solution' i suggested in my 2nd post is going to be 
the way to do it, but i just don't know how to do that.



[*~ 2048]
|
[expr~ $v1%2048]
|
[/~ 2048]


thanks.  that's what i had done originally, but i couldn't hear any 
effect.  i guess if i really want 12-bit sound in pd, i'd have to use 
that construct after each and every calculation in the signal chain. 
seems a fair bit of overkill just to make the sound WORSE though! 





Well 12-bit sound is pretty good, as good as audio cassette with no 
dolby. You should try replacing 2048 with 128 or less to hear true lo-fi.


Martin




___
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management - 
http://lists.puredata.info/listinfo/pd-list