[music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and 
add it to phase

if(phase >= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine. 
but as soon as overtones are added i get the fluttering)


My problem is that i get periodic amplitude modulations on the overtones 
about 2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone 
frequency, the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some 
ringing on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw 
wavetable. but the flutter is the same, no matter if i use a bandlimited 
WT or output the phase counter directly)

the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter. 
but i can't get my head around whats wrong.

any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Ross Bencina

Hello Julian,

Assuming all variables are integers, if phase doesn't divide TABLESIZE 
then you will get a different waveform amplutude for adjacent cycles. 
Perhaps that's what you're seeing?


At each cycle start the he value of phase will be different. The pattern 
of different waveforms will repeat at the rate of the LCM of phaseInc 
and TABLESIZE.


Usually you would use a fixed point phase accumulator and phase 
increment so you can have subsample accurate increment. That won't 
change the fact that frequencies that don't have an integer-sample 
period will look different each cycle.


Ross.



On 9/04/2012 11:28 PM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and
add it to phase
if(phase >= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine.
but as soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the overtones
about 2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone
frequency, the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some
ringing on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw
wavetable. but the flutter is the same, no matter if i use a bandlimited
WT or output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter.
but i can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

Am 09.04.2012 16:24, schrieb Ross Bencina:

Hello Julian,

Assuming all variables are integers, if phase doesn't divide TABLESIZE 
then you will get a different waveform amplutude for adjacent cycles. 
Perhaps that's what you're seeing?


oh sorry, i forgot to mention.

the phase accumulator is a float.
as well as the phaseIncrement value.

I know that my waveform will start on different amplitudes, but the 
effect  i'm hearing is very audible.

like a "click" noise about 2-3 times a second.
the root frequency is unaffected, around 10kHz it's a 6dB drop in 
frequency, at 20kHz its allready12dB.

the error from the floating point phase wrapping shouldn't be THAT audible.

what confuses me is that i coded a lot of wavetable OSCs on PCand never 
had any problems with phase wrap noise.


maybe it's a problem related to the hardware... I'm new to the cortex m4.
could it have to do with a frequency error on the I2S bus?
The I2S bus is configured to run on 44100Hz
but due to prescalers and external xtal frequency i can only get an 
actual SR of 44002.75Hz SR


so when i generate a waveform of 440Hz it is nearly a multiple of the SR 
my audio codec is running on.


julian


At each cycle start the he value of phase will be different. The 
pattern of different waveforms will repeat at the rate of the LCM of 
phaseInc and TABLESIZE.


Usually you would use a fixed point phase accumulator and phase 
increment so you can have subsample accurate increment. That won't 
change the fact that frequencies that don't have an integer-sample 
period will look different each cycle.


Ross.



On 9/04/2012 11:28 PM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and
add it to phase
if(phase >= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine.
but as soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the overtones
about 2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone
frequency, the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some
ringing on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw
wavetable. but the flutter is the same, no matter if i use a bandlimited
WT or output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter.
but i can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book 
reviews, dsp links

http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Olli Niemitalo
If you don't interpolate the wavetable then you may be simply getting
some aliasing problems. Every Nth cycle of the generated waveform will
be one sample shorter than the others, and that will sound like a
click. Try setting your phaseInc to an integer value. Also, somewhere
along the analog signal chain you may be getting nonlinearities with
the Gibbs phenomenon peaks if you are running your wavetable
oscillator at full-scale amplitude. Try reducing the wavetable
amplitude.

-olli

On Mon, Apr 9, 2012 at 4:28 PM, Julian Schmidt
 wrote:

> phase += phaseInc(440); // calculate the phase increment for 440 hz and add
> it to phase
> if(phase >= TABLESIZE) phase -= TABLESIZE;
> return phase/TABLESIZE;
>
> [...] My problem is that i get periodic amplitude modulations on the overtones
> about 2-3 times a second.
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

okay i tried your suggestion.
reducing the wavetable amplitude to 0.8 instead of 1 changed nothing.
but it isn't a clipping problem.
no nonlinea frequencies are added.
The signal only consists of the right harmonic overtones

setting the phase increment to an integer value solves the problem.
but it has the drawback that i can't hit exact frequencies anymore.

for example with a table size of 512 samples and 44100kHz SR
when i use a phase increment of 5 i get 44.1kHz / 512 * 5 = 430.66 Hz
the next phase inc. 6 would give 44.1kHz / 512*6 = 516,79 Hz
everything in between is inaccessible. so no 440Hz possible.

adding linear or cubic interpolation makes it a little better, but the 
pulsing is still very audible.


but it has definitely to do with the phase wrap. The nearer i get to an 
integer phase increment, the slower the amplitude of the harmonics is 
pulsating. at an integer value it stops.


what is the correct way to implement the wavetable osc to stop the 
overtone pulsing without using hge wavetables?


julian



Am 09.04.2012 17:38, schrieb Olli Niemitalo:

If you don't interpolate the wavetable then you may be simply getting
some aliasing problems. Every Nth cycle of the generated waveform will
be one sample shorter than the others, and that will sound like a
click. Try setting your phaseInc to an integer value. Also, somewhere
along the analog signal chain you may be getting nonlinearities with
the Gibbs phenomenon peaks if you are running your wavetable
oscillator at full-scale amplitude. Try reducing the wavetable
amplitude.

-olli

On Mon, Apr 9, 2012 at 4:28 PM, Julian Schmidt
  wrote:


phase += phaseInc(440); // calculate the phase increment for 440 hz and add
it to phase
if(phase>= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

[...] My problem is that i get periodic amplitude modulations on the overtones
about 2-3 times a second.

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Nigel Redmon
Interesting...my STM32F4DISCOVERY just arrive Friday...intending to make a 
wavetable oscillator on it, fist thing...

Are you writing the wavetable to a buffer, then pulling from that at the sample 
rate? if so, what size?



On Apr 9, 2012, at 6:28 AM, Julian Schmidt wrote:
> Hello all,
> 
> I'm trying to get an oscillator running on the STM32F4 discovery board.
> I'm sending my audio with 44100Hz via I2S to the onboard codec.
> However I'm experiencing strange problems.
> 
> my code ist quite straight forward:
> 
> phase += phaseInc(440); // calculate the phase increment for 440 hz and add 
> it to phase
> if(phase >= TABLESIZE) phase -= TABLESIZE;
> return phase/TABLESIZE;
> 
> this should give me a non bw limited saw from 0 to 1.f
> (I also tried it with an actual wavetable in use. a sine is played fine. but 
> as soon as overtones are added i get the fluttering)
> 
> My problem is that i get periodic amplitude modulations on the overtones 
> about 2-3 times a second.
> the root frequency amplitude is fixed, but the higher the overtone frequency, 
> the more it's amplitude drops every now and then.
> this screenshot illustrates the waveform. the upper waveform has some ringing 
> on the discontinuity and the lower has not.
> http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw 
> wavetable. but the flutter is the same, no matter if i use a bandlimited WT 
> or output the phase counter directly)
> the waveform oscillates between the upper and the lower image.
> 
> the amplitude flutter from the overtones is also frequency dependent.
> at 439 and 441 Hz its not really audible.
> 
> so my tought is that is has to do with the wrap of the phase counter. but i 
> can't get my head around whats wrong.
> any ideas where this change in overtone amplitude could come from?
> 
> cheers,
> julian
> 
> 
> 
> 
> 
> 
> --
> dupswapdrop -- the music-dsp mailing list and website:
> subscription info, FAQ, source code archive, list archive, book reviews, dsp 
> links
> http://music.columbia.edu/cmc/music-dsp
> http://music.columbia.edu/mailman/listinfo/music-dsp

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread robert bristow-johnson


i hadn't heard of this dev board before.  at 
http://www.st.com/internet/evalboard/product/252419.jsp it says that the 
single unit prices is US$14.9 .  is that right?  that's nearly free.


where do the software tools (the compiler/linker/loader/etc) come from?

regarding wavetable indexing, somewhere Julian must be converting float 
to int, no?  i am still convinced that the correct way to implement it 
is with pure integer arithmetic.  to implement a good NCO, you need a 
lot of bits in the phase accumulator.  i might think that 32 would be 
enough.  if there are 256 points in the wavetable, then the top 8 bits 
go to indexing into the wavetable and the bottom 24 bits are used for 
interpolation between points.  usually, for mid-quality synthesis, a 
256-point wavetable oughta be good enough, but you might want it a 
little bigger.  maybe 1024 points.  that leaves 22 bits for the 
interpolation.  if you have enough points in the wavetable, then linear 
interpolation oughta be good enough.


Julian, are are you willing to plop up more code?  if you want, i'll dig 
up a snippet for how to do this without if statements and without 
floating-point phase accumulator.  and with linear interpolation.  it's 
pretty straight forward.


--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."





On 4/9/12 12:51 PM, Nigel Redmon wrote:

Interesting...my STM32F4DISCOVERY just arrive Friday...intending to make a 
wavetable oscillator on it, first thing...

Are you writing the wavetable to a buffer, then pulling from that at the sample 
rate? if so, what size?



On Apr 9, 2012, at 6:28 AM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and add it 
to phase
if(phase>= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine. but as 
soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the overtones about 
2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone frequency, 
the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some ringing 
on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw 
wavetable. but the flutter is the same, no matter if i use a bandlimited WT or 
output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter. but i 
can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

at the moment I use a sample based I2S interrupt (44.1 16-bit stereo).
the alternative would be a direct DMA to feed the codec (all buffersizes 
up to 0x are supported).

but for the moment i decided on latency free sample based calculations.

I've also got a state variable filter running on the board, which is 
working fine.


julian

Am 09.04.2012 18:51, schrieb Nigel Redmon:

Interesting...my STM32F4DISCOVERY just arrive Friday...intending to make a 
wavetable oscillator on it, fist thing...

Are you writing the wavetable to a buffer, then pulling from that at the sample 
rate? if so, what size?



On Apr 9, 2012, at 6:28 AM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and add it 
to phase
if(phase>= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine. but as 
soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the overtones about 
2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone frequency, 
the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some ringing 
on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw 
wavetable. but the flutter is the same, no matter if i use a bandlimited WT or 
output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter. but i 
can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Paul Schreiber
Yes, that's the price. I have like 3 of them before someone gets wise :)

Paul S.


-Original Message-
From: music-dsp-boun...@music.columbia.edu
[mailto:music-dsp-boun...@music.columbia.edu] On Behalf Of robert
bristow-johnson
Sent: Monday, April 09, 2012 12:17 PM
To: music-dsp@music.columbia.edu
Subject: Re: [music-dsp] OSC problem on STM32F4Discovery


i hadn't heard of this dev board before.  at
http://www.st.com/internet/evalboard/product/252419.jsp it says that the
single unit prices is US$14.9 .  is that right?  that's nearly free.

where do the software tools (the compiler/linker/loader/etc) come from?

regarding wavetable indexing, somewhere Julian must be converting float to
int, no?  i am still convinced that the correct way to implement it is with
pure integer arithmetic.  to implement a good NCO, you need a lot of bits in
the phase accumulator.  i might think that 32 would be enough.  if there are
256 points in the wavetable, then the top 8 bits go to indexing into the
wavetable and the bottom 24 bits are used for interpolation between points.
usually, for mid-quality synthesis, a 256-point wavetable oughta be good
enough, but you might want it a little bigger.  maybe 1024 points.  that
leaves 22 bits for the interpolation.  if you have enough points in the
wavetable, then linear interpolation oughta be good enough.

Julian, are are you willing to plop up more code?  if you want, i'll dig up
a snippet for how to do this without if statements and without
floating-point phase accumulator.  and with linear interpolation.  it's
pretty straight forward.

-- 

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."





On 4/9/12 12:51 PM, Nigel Redmon wrote:
> Interesting...my STM32F4DISCOVERY just arrive Friday...intending to make a
wavetable oscillator on it, first thing...
>
> Are you writing the wavetable to a buffer, then pulling from that at the
sample rate? if so, what size?
>
>
>
> On Apr 9, 2012, at 6:28 AM, Julian Schmidt wrote:
>> Hello all,
>>
>> I'm trying to get an oscillator running on the STM32F4 discovery board.
>> I'm sending my audio with 44100Hz via I2S to the onboard codec.
>> However I'm experiencing strange problems.
>>
>> my code ist quite straight forward:
>>
>> phase += phaseInc(440); // calculate the phase increment for 440 hz 
>> and add it to phase if(phase>= TABLESIZE) phase -= TABLESIZE; return 
>> phase/TABLESIZE;
>>
>> this should give me a non bw limited saw from 0 to 1.f (I also tried 
>> it with an actual wavetable in use. a sine is played fine. but as 
>> soon as overtones are added i get the fluttering)
>>
>> My problem is that i get periodic amplitude modulations on the overtones
about 2-3 times a second.
>> the root frequency amplitude is fixed, but the higher the overtone
frequency, the more it's amplitude drops every now and then.
>> this screenshot illustrates the waveform. the upper waveform has some
ringing on the discontinuity and the lower has not.
>> http://i.imgur.com/JyuEr.png (this image is taken from an inverted 
>> saw wavetable. but the flutter is the same, no matter if i use a
bandlimited WT or output the phase counter directly) the waveform oscillates
between the upper and the lower image.
>>
>> the amplitude flutter from the overtones is also frequency dependent.
>> at 439 and 441 Hz its not really audible.
>>
>> so my tought is that is has to do with the wrap of the phase counter. but
i can't get my head around whats wrong.
>> any ideas where this change in overtone amplitude could come from?
>>
>> cheers,
>> julian
>>
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp
links http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

Am 09.04.2012 19:16, schrieb robert bristow-johnson:


i hadn't heard of this dev board before.  at 
http://www.st.com/internet/evalboard/product/252419.jsp it says that 
the single unit prices is US$14.9 .  is that right?  that's nearly free.


yes exactly. it's cheaper than buying the cortex m4 chip alone.
and you get a stereo codec (with limiter and equalizer), a class d 
amplifier, a accelerometer and a mic for free.


a programmer/debugger is also directly on the dev board (st-link via usb)


where do the software tools (the compiler/linker/loader/etc) come from?


at the moment i'm using a free toolchain consisting of
Eclipse,
ARM GCC
and the st-link-gdb server delivered with the free version of attolic 
studio.


there is also a stand alone loader tool for the st-link.


regarding wavetable indexing, somewhere Julian must be converting 
float to int, no?  i am still convinced that the correct way to 
implement it is with pure integer arithmetic. 


yes, the codec expects signed 16-bit integer as input.
and for the table index I slit the phase result to an integer and a 
fractional value as float (used for the interpolation)
The integer arithmetic point could be valid. 2 or 3 years ago i made a 
AVR wavetable synth and i can't remember any fluttering overtones there. 
The AVR used an integer phase accumulator.




to implement a good NCO, you need a lot of bits in the phase 
accumulator.  i might think that 32 would be enough.  if there are 256 
points in the wavetable, then the top 8 bits go to indexing into the 
wavetable and the bottom 24 bits are used for interpolation between 
points.  usually, for mid-quality synthesis, a 256-point wavetable 
oughta be good enough, but you might want it a little bigger.  maybe 
1024 points.  that leaves 22 bits for the interpolation.  if you have 
enough points in the wavetable, then linear interpolation oughta be 
good enough.


Julian, are are you willing to plop up more code?  if you want, i'll 
dig up a snippet for how to do this without if statements and without 
floating-point phase accumulator.  and with linear interpolation.  
it's pretty straight forward.


If I can't get it to work that would be very welcome.
I guess I'll try to implement an integer version now, and if that 
doesn't work i'll get back with more code. ;)


thanks a lot for the help so far.

julian

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Gwenhwyfaer
On 09/04/2012, robert bristow-johnson  wrote:
>
> i hadn't heard of this dev board before.  at
> http://www.st.com/internet/evalboard/product/252419.jsp it says that the
> single unit prices is US$14.9 .  is that right?  that's nearly free.

They were giving them out free in the US for a while, I believe.

> regarding wavetable indexing, somewhere Julian must be converting float
> to int, no?  i am still convinced that the correct way to implement it
> is with pure integer arithmetic.  to implement a good NCO, you need a
> lot of bits in the phase accumulator.  i might think that 32 would be
> enough.

And therein, I suspect, lies the problem; the STM32F4 is a Cortex M4F
implementation, which means it has a single-precision FPU onboard - ie
only 24 bits of precision. I have a feeling that what's in evidence
here is just rounding error. Especially given that the problem only
manifests when the difference between the phase increment and a
multiple of the sample rate is really small.
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Gwenhwyfaer
On 09/04/2012, Julian Schmidt  wrote:
> yes exactly. it's cheaper than buying the cortex m4 chip alone.
> and you get a stereo codec (with limiter and equalizer)

Stupid question, but the limiter is turned off, isn't it...?
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

yes. that was the first place i looked, the codec datasheet. ;)
limiter, de-emphasis, tone control are all turned off
gain is about 50% of the possible amplitude.

julian

Am 09.04.2012 19:38, schrieb Gwenhwyfaer:

On 09/04/2012, Julian Schmidt  wrote:

yes exactly. it's cheaper than buying the cortex m4 chip alone.
and you get a stereo codec (with limiter and equalizer)

Stupid question, but the limiter is turned off, isn't it...?
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Nigel Redmon

On Apr 9, 2012, at 10:16 AM, robert bristow-johnson wrote:
> i hadn't heard of this dev board before.  at 
> http://www.st.com/internet/evalboard/product/252419.jsp it says that the 
> single unit prices is US$14.9 .  is that right?  that's nearly free.

Yes, from Mouser. With tax and UPS ground, it was $25 and change, ordered on 
Wednesday, showed up on Friday...that and a USB A to mini B cable (power and 
communication), and the nice LED light show runs to prove it's working.

Funny part is that the board is a little cheaper than the chip itself—heckova 
deal...

What lead me to it was thinking of making some electronic goodies, and deciding 
it would be nice to be lazy and do it in C/C++, in floating point...(M4F is 
single precision fp).

> where do the software tools (the compiler/linker/loader/etc) come from?

Some integrated solutions, some of which are pricey but have free 
limit-code-size versions...sufficient totally free paths (gnu tool chains, free 
embedded RTOS)...I'm at the start of that learning curve; There are free 
integrated routes that will run the STM demos out of the box easily, but I'm 
planning to go the less convenient route and get it going on my Mac Pro, just 
because I like it better as an editor, mainly, and am more comfortable with the 
UNIX tools there. It looks pretty easy to get up a "bare metal" tool chain and 
work with the command line, but I started looking into getting it going via 
Eclipse—was short on time to finish that this weekend...


> regarding wavetable indexing, somewhere Julian must be converting float to 
> int, no?  i am still convinced that the correct way to implement it is with 
> pure integer arithmetic.  to implement a good NCO, you need a lot of bits in 
> the phase accumulator.  i might think that 32 would be enough.  if there are 
> 256 points in the wavetable, then the top 8 bits go to indexing into the 
> wavetable and the bottom 24 bits are used for interpolation between points.  
> usually, for mid-quality synthesis, a 256-point wavetable oughta be good 
> enough, but you might want it a little bigger.  maybe 1024 points.  that 
> leaves 22 bits for the interpolation.  if you have enough points in the 
> wavetable, then linear interpolation oughta be good enough.
> 
> Julian, are are you willing to plop up more code?  if you want, i'll dig up a 
> snippet for how to do this without if statements and without floating-point 
> phase accumulator.  and with linear interpolation.  it's pretty straight 
> forward.
> 
> -- 
> 
> r b-j  r...@audioimagination.com
> 
> "Imagination is more important than knowledge."
> 
> 
> 
> 
> 
> On 4/9/12 12:51 PM, Nigel Redmon wrote:
>> Interesting...my STM32F4DISCOVERY just arrive Friday...intending to make a 
>> wavetable oscillator on it, first thing...
>> 
>> Are you writing the wavetable to a buffer, then pulling from that at the 
>> sample rate? if so, what size?
>> 
>> 
>> 
>> On Apr 9, 2012, at 6:28 AM, Julian Schmidt wrote:
>>> Hello all,
>>> 
>>> I'm trying to get an oscillator running on the STM32F4 discovery board.
>>> I'm sending my audio with 44100Hz via I2S to the onboard codec.
>>> However I'm experiencing strange problems.
>>> 
>>> my code ist quite straight forward:
>>> 
>>> phase += phaseInc(440); // calculate the phase increment for 440 hz and add 
>>> it to phase
>>> if(phase>= TABLESIZE) phase -= TABLESIZE;
>>> return phase/TABLESIZE;
>>> 
>>> this should give me a non bw limited saw from 0 to 1.f
>>> (I also tried it with an actual wavetable in use. a sine is played fine. 
>>> but as soon as overtones are added i get the fluttering)
>>> 
>>> My problem is that i get periodic amplitude modulations on the overtones 
>>> about 2-3 times a second.
>>> the root frequency amplitude is fixed, but the higher the overtone 
>>> frequency, the more it's amplitude drops every now and then.
>>> this screenshot illustrates the waveform. the upper waveform has some 
>>> ringing on the discontinuity and the lower has not.
>>> http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw 
>>> wavetable. but the flutter is the same, no matter if i use a bandlimited WT 
>>> or output the phase counter directly)
>>> the waveform oscillates between the upper and the lower image.
>>> 
>>> the amplitude flutter from the overtones is also frequency dependent.
>>> at 439 and 441 Hz its not really audible.
>>> 
>>> so my tought is that is has to do with the wrap of the phase counter. but i 
>>> can't get my head around whats wrong.
>>> any ideas where this change in overtone amplitude could come from?
>>> 
>>> cheers,
>>> julian
>>> 
> --
> dupswapdrop -- the music-dsp mailing list and website:
> subscription info, FAQ, source code archive, list archive, book reviews, dsp 
> links
> http://music.columbia.edu/cmc/music-dsp
> http://music.columbia.edu/mailman/listinfo/music-dsp

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, 

Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread robert bristow-johnson

On 4/9/12 1:29 PM, Julian Schmidt wrote:

Am 09.04.2012 19:16, schrieb robert bristow-johnson:


i hadn't heard of this dev board before.  at 
http://www.st.com/internet/evalboard/product/252419.jsp it says that 
the single unit prices is US$14.9 .  is that right?  that's nearly free.


yes exactly. it's cheaper than buying the cortex m4 chip alone.
and you get a stereo codec (with limiter and equalizer), a class d 
amplifier, a accelerometer and a mic for free.


a programmer/debugger is also directly on the dev board (st-link via usb)


where do the software tools (the compiler/linker/loader/etc) come from?


at the moment i'm using a free toolchain consisting of
Eclipse,
ARM GCC
and the st-link-gdb server delivered with the free version of attolic 
studio.


there is also a stand alone loader tool for the st-link.



i just ordered the board from Mouser.  ($14.87 + cheapest USPS shipping)

i'll bother you guys later about getting the software tools and figuring 
out how to do a development cycle.




regarding wavetable indexing, somewhere Julian must be converting 
float to int, no?  i am still convinced that the correct way to 
implement it is with pure integer arithmetic. 


yes, the codec expects signed 16-bit integer as input.


yeah, that's that (yet) the issue.

and for the table index I slit the phase result to an integer and a 
fractional value as float (used for the interpolation)


how do you do that cleanly?



The integer arithmetic point could be valid.


i think it's the only correct way to do it.  maybe not.

2 or 3 years ago i made a AVR wavetable synth and i can't remember any 
fluttering overtones there. The AVR used an integer phase accumulator.





unsigned long phase_accumulator=0L, phase_increment, wavetable_index, 
fractional_index;

float interp_value, waveform_out;
float wavetable[1025];   // one extra point for doing linear interpolation
 // make sure that wavetable[1024] = wavetable[0]

...

  wavetable_index = phase_accumulator >> 22;
  fractional_index = phase_accumulator & 0x003F;
  interp_value = 2.38418579101562e-07 * (float)fractional_index;
  waveform_out = wavetable[wavetable_index++];
  waveform_out += interp_value*(wavetable[wavetable_index] - waveform_out);
  phase_accumulator += phase_increment;


can't get much simpler than that.  no "if" statement and the 
phase_accumulator wraps around naturally.



to implement a good NCO, you need a lot of bits in the phase 
accumulator.  i might think that 32 would be enough.  if there are 
256 points in the wavetable, then the top 8 bits go to indexing into 
the wavetable and the bottom 24 bits are used for interpolation 
between points.  usually, for mid-quality synthesis, a 256-point 
wavetable oughta be good enough, but you might want it a little 
bigger.  maybe 1024 points.  that leaves 22 bits for the 
interpolation.  if you have enough points in the wavetable, then 
linear interpolation oughta be good enough.


Julian, are are you willing to plop up more code?  if you want, i'll 
dig up a snippet for how to do this without if statements and without 
floating-point phase accumulator.  and with linear interpolation.  
it's pretty straight forward.


If I can't get it to work that would be very welcome.
I guess I'll try to implement an integer version now, and if that 
doesn't work i'll get back with more code. ;)


thanks a lot for the help so far.



FWIW.

--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Olli Niemitalo
On Mon, Apr 9, 2012 at 7:17 PM, Julian Schmidt
 wrote:

> setting the phase increment to an integer value solves the problem.
> [...]
> adding linear or cubic interpolation makes it a little better, but the
> pulsing is still very audible.
> [...]
> The nearer i get to an integer phase increment, the slower the amplitude
> of the harmonics is pulsating. at an integer value it stops.

All of these findings support the hypothesis that it is an aliasing
problem. So it doesn't need to have to do with phase wrapping. Saw
wave and similarly discontinuous waveforms are particularly nasty when
it comes to aliasing problems because the harmonics decay so slowly
(amplitude of Nth harmonic = 1/N). I bet the reason why you had so
little problems with the sine wave is because it was greatly
oversampled (that is, the highest frequency, in this case the
fundamental frequency, is less than sampling frequency / 2).

Do a mental check on what the bandwidth of your wavetable is, and
whether you will get aliasing by playing back the wavetable at a
different rate than 1:1 and by resampling it to the target sampling
frequency.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Eric Brombaugh

On 04/09/2012 10:16 AM, robert bristow-johnson wrote:


i hadn't heard of this dev board before. at
http://www.st.com/internet/evalboard/product/252419.jsp it says that the
single unit prices is US$14.9 . is that right? that's nearly free.

where do the software tools (the compiler/linker/loader/etc) come from?


ST vectors you off to one of a number of different professional-grade 
compilers from the likes of Keil, IAR and Atollic (possibly others). 
Some of these have demo/crippleware versions with limited code size that 
can be had for the cost of your marketing information.


I've been using GCC + other OSS tools with reasonably good luck. The 
latest free versions of GCC from CodeSourcery support the Cortex M4 and 
its FPU. Linker scripts and C startup source is available in the ST 
peripheral library available from their website.


Eric
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

I think you win! ;)

first i tried switching to integer phase accumulators like RBJ suggested.
It sounded exacly the same.

I really think it is an aliasing problem.
but not due to the wrong wavetable content, but due to a cheap audio 
codec with poor filters.


I toyed around with the mip mapping settings of the limited saw table 
and an FFT analyzer.
even when i output a single 440hz sine i get harmonics starting at -48db 
up to nyquist and beyond.
the amplidude of these harmonics increases as i increase the number of 
sines in my wavetable.


if i play 10 harmonics from the saw table at 440Hz beginning from the 
4th harmonic I see that harmonics are damped or increased in the shape 
of the codecs filter stopband riffle ( 4th and 5th harmonic damped, than 
amplified in a bell shape)
the harmonics go up to nyquist (allthoug the higher ones are in the 
range ob -60 to -66dB)


with the right amount of harmonics i get a 4dB beating at 6.5Khz at -30dB
and a 30dB beating at around 12kHz at around -42dB again in the shape of 
a bell like in the codecs stopband ripple


I think now i will activate the tone control of the codec and see if 
that can surpress the bleeding harmonics.


julian




Am 09.04.2012 20:28, schrieb Olli Niemitalo:

On Mon, Apr 9, 2012 at 7:17 PM, Julian Schmidt
  wrote:


setting the phase increment to an integer value solves the problem.
[...]
adding linear or cubic interpolation makes it a little better, but the
pulsing is still very audible.
[...]
The nearer i get to an integer phase increment, the slower the amplitude
of the harmonics is pulsating. at an integer value it stops.

All of these findings support the hypothesis that it is an aliasing
problem. So it doesn't need to have to do with phase wrapping. Saw
wave and similarly discontinuous waveforms are particularly nasty when
it comes to aliasing problems because the harmonics decay so slowly
(amplitude of Nth harmonic = 1/N). I bet the reason why you had so
little problems with the sine wave is because it was greatly
oversampled (that is, the highest frequency, in this case the
fundamental frequency, is less than sampling frequency / 2).

Do a mental check on what the bandwidth of your wavetable is, and
whether you will get aliasing by playing back the wavetable at a
different rate than 1:1 and by resampling it to the target sampling
frequency.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

here are some screenshots...

the beating bell shape on 440Hz sinus with 84 harmonics
http://i.imgur.com/B4s0M.png

a simple sine table 220Hz
http://i.imgur.com/hPKj1.png

julian


Am 09.04.2012 22:32, schrieb Julian Schmidt:

I think you win! ;)

first i tried switching to integer phase accumulators like RBJ suggested.
It sounded exacly the same.

I really think it is an aliasing problem.
but not due to the wrong wavetable content, but due to a cheap audio 
codec with poor filters.


I toyed around with the mip mapping settings of the limited saw table 
and an FFT analyzer.
even when i output a single 440hz sine i get harmonics starting at 
-48db up to nyquist and beyond.
the amplidude of these harmonics increases as i increase the number of 
sines in my wavetable.


if i play 10 harmonics from the saw table at 440Hz beginning from the 
4th harmonic I see that harmonics are damped or increased in the shape 
of the codecs filter stopband riffle ( 4th and 5th harmonic damped, 
than amplified in a bell shape)
the harmonics go up to nyquist (allthoug the higher ones are in the 
range ob -60 to -66dB)


with the right amount of harmonics i get a 4dB beating at 6.5Khz at -30dB
and a 30dB beating at around 12kHz at around -42dB again in the shape 
of a bell like in the codecs stopband ripple


I think now i will activate the tone control of the codec and see if 
that can surpress the bleeding harmonics.


julian




Am 09.04.2012 20:28, schrieb Olli Niemitalo:

On Mon, Apr 9, 2012 at 7:17 PM, Julian Schmidt
  wrote:


setting the phase increment to an integer value solves the problem.
[...]
adding linear or cubic interpolation makes it a little better, but the
pulsing is still very audible.
[...]
The nearer i get to an integer phase increment, the slower the 
amplitude

of the harmonics is pulsating. at an integer value it stops.

All of these findings support the hypothesis that it is an aliasing
problem. So it doesn't need to have to do with phase wrapping. Saw
wave and similarly discontinuous waveforms are particularly nasty when
it comes to aliasing problems because the harmonics decay so slowly
(amplitude of Nth harmonic = 1/N). I bet the reason why you had so
little problems with the sine wave is because it was greatly
oversampled (that is, the highest frequency, in this case the
fundamental frequency, is less than sampling frequency / 2).

Do a mental check on what the bandwidth of your wavetable is, and
whether you will get aliasing by playing back the wavetable at a
different rate than 1:1 and by resampling it to the target sampling
frequency.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book 
reviews, dsp links

http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book 
reviews, dsp links

http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Olli Niemitalo
On Mon, Apr 9, 2012 at 11:32 PM, Julian Schmidt
 wrote:
> I really think it is an aliasing problem.
> but not due to the wrong wavetable content, but due to a cheap audio codec
> with poor filters.
> [...]
> even when i output a single 440hz sine i get harmonics starting at -48db up
> to nyquist and beyond.

Lemme guess your wavetable size is 256? That's the amount of
distortion that would be expected from using "no interpolation". If
that's what you have then the codec is not at fault.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Julian Schmidt

Am 09.04.2012 23:22, schrieb Olli Niemitalo:

On Mon, Apr 9, 2012 at 11:32 PM, Julian Schmidt
  wrote:

I really think it is an aliasing problem.
but not due to the wrong wavetable content, but due to a cheap audio codec
with poor filters.
[...]
even when i output a single 440hz sine i get harmonics starting at -48db up
to nyquist and beyond.

Lemme guess your wavetable size is 256? That's the amount of
distortion that would be expected from using "no interpolation". If
that's what you have then the codec is not at fault.


i use code similar to what RBJ has posted with linear interpolation 
(although with a tablesize of 256 at the moment).


julian


-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Olli Niemitalo
On Tue, Apr 10, 2012 at 12:25 AM, Julian Schmidt
 wrote:
> Am 09.04.2012 23:22, schrieb Olli Niemitalo:
>
>> On Mon, Apr 9, 2012 at 11:32 PM, Julian Schmidt
>>   wrote:
>>>
>>> I really think it is an aliasing problem.
>>> but not due to the wrong wavetable content, but due to a cheap audio
>>> codec with poor filters.
>>> [...]
>>> even when i output a single 440hz sine i get harmonics starting at -48db
>>> up to nyquist and beyond.
>>
>> Lemme guess your wavetable size is 256? That's the amount of
>> distortion that would be expected from using "no interpolation". If
>> that's what you have then the codec is not at fault.
>
> i use code similar to what RBJ has posted with linear interpolation
> (although with a tablesize of 256 at the moment).

Okay, that should give a -96 dB spectral distortion floor for a
single-sinusoid wavetable, compared to your -48 dB. If the codec is
causing all that then it should also show up if you use a sin()
function instead of playing back the wavetable. I'm just a bit
skeptical because the specs of the codec don't seem that bad.

-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


[music-dsp] testing 1,2,3

2012-04-09 Thread robert bristow-johnson


i dunno why, but i can no longer reply to the thread that Julian 
started.  if this post gets to the list, then i think there is some 
damaged header or something.  this has happened to me before and it only 
happens with this mailing list.


after hitting "Send", Thunderbird tries sending it and replies:

"Alert

An error occurred while sending mail. The mail server responded:  5.7.1 
q39M5gal023047 This message does not comply with required standards.. 
Please check the message and try again."


and it does that even if i change the To: header and try to mail it to 
myself.


does anyone know what is wrong?  this message is a *new* message 
(without replying, so the headers should be cleaner).  if this message 
goes and the other one refuses to go, all i can think of is that there 
is a damaged header.


Douglas, dunno if the list server is doing this, but i thought you 
should know.


--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


[music-dsp] [ot] Re: testing 1,2,3

2012-04-09 Thread douglas repetto


Robert,

I haven't heard of anything like that. It's unlikely that it's the list 
software complaining, sounds more like the server itself. And since 
others are replying to the thread it's probable that the header damage 
(if that's the problem) is happening on your machine rather than on the 
server. Maybe? I dunno!


douglas


On 4/9/12 6:09 PM, robert bristow-johnson wrote:


i dunno why, but i can no longer reply to the thread that Julian
started. if this post gets to the list, then i think there is some
damaged header or something. this has happened to me before and it only
happens with this mailing list.

after hitting "Send", Thunderbird tries sending it and replies:

"Alert

An error occurred while sending mail. The mail server responded: 5.7.1
q39M5gal023047 This message does not comply with required standards..
Please check the message and try again."

and it does that even if i change the To: header and try to mail it to
myself.

does anyone know what is wrong? this message is a *new* message (without
replying, so the headers should be cleaner). if this message goes and
the other one refuses to go, all i can think of is that there is a
damaged header.

Douglas, dunno if the list server is doing this, but i thought you
should know.



--
... http://artbots.org
.douglas.irving http://dorkbot.org
.. http://music.columbia.edu/cmc/music-dsp
...repetto. http://music.columbia.edu/organism
... http://music.columbia.edu/~douglas

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


[music-dsp] testing 1,2,3...

2012-04-09 Thread robert bristow-johnson


[this is a fresh message, not a reply to any other, since none of those 
seem to get past my SMTP server.]


On 4/9/12 5:25 PM, Julian Schmidt wrote:
> Am 09.04.2012 23:22, schrieb Olli Niemitalo:
>> On Mon, Apr 9, 2012 at 11:32 PM, Julian Schmidt
>>   wrote:
>>> I really think it is an aliasing problem.
>>> but not due to the wrong wavetable content, but due to a cheap audio
>>> codec
>>> with poor filters.
>>> [...]
>>> even when i output a single 440hz sine i get harmonics starting at
>>> -48db up
>>> to nyquist and beyond.
>> Lemme guess your wavetable size is 256? That's the amount of
>> distortion that would be expected from using "no interpolation". If
>> that's what you have then the codec is not at fault.
>
> i use code similar to what RBJ has posted with linear interpolation
> (although with a tablesize of 256 at the moment).
>

okay, since i didn't write it to be bullet proof (i just kludged it 
together for illustration purposes), you would need to change a couple 
of things.  in case you realized that and made the correct 
modifications, please do not take offense.  but if you didn't fix 
everything (the >>24 bit shift instead of >>22 bits, the masking to get 
fractional_index, the scaler to get interp_value), the resulting error 
could be as large as no interpolation.


here is the update on that:

unsigned long phase_accumulator=0L, phase_increment, wavetable_index, 
fractional_index;

float interp_value, waveform_out;
float wavetable[257];   // one extra point for doing linear interpolation
// make sure that wavetable[256] = wavetable[0]

...

  wavetable_index = phase_accumulator >> 24;
  fractional_index = phase_accumulator & 0x00FF;
  interp_value = 5.96046447753906e-08 * (float)fractional_index;
  waveform_out = wavetable[wavetable_index++];
  waveform_out += interp_value*(wavetable[wavetable_index] - waveform_out);
  phase_accumulator += phase_increment;

determining the phase_increment would actually be unchanged.  a 
phase_increment of 0x1000 would be 1/16 cycle per sample, no matter 
how big the wavetable is.


have you tried setting up a simple stereo "wire" program that just 
passes the audio through the cheap audio codec?


when does this board sound good?  at least a "wire" should pass audio 
reasonably decently.


i don't get why aliasing from a cheap codec would cause a fluttering 
sound.  unless the aliasing was s bad that the aliased sinusoids are 
about the same size as some in the baseband.  usually aliasing from low 
sample rate just causes a cheap, grungy sound.


do you know if your codec's clock is solid?

--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread douglas repetto


Just a test reply to see if I have the same problem Robert's having...

douglas

On 4/9/12 10:43 AM, Julian Schmidt wrote:

Am 09.04.2012 16:24, schrieb Ross Bencina:

Hello Julian,

Assuming all variables are integers, if phase doesn't divide TABLESIZE
then you will get a different waveform amplutude for adjacent cycles.
Perhaps that's what you're seeing?


oh sorry, i forgot to mention.

the phase accumulator is a float.
as well as the phaseIncrement value.

I know that my waveform will start on different amplitudes, but the
effect i'm hearing is very audible.
like a "click" noise about 2-3 times a second.
the root frequency is unaffected, around 10kHz it's a 6dB drop in
frequency, at 20kHz its allready12dB.
the error from the floating point phase wrapping shouldn't be THAT audible.

what confuses me is that i coded a lot of wavetable OSCs on PCand never
had any problems with phase wrap noise.

maybe it's a problem related to the hardware... I'm new to the cortex m4.
could it have to do with a frequency error on the I2S bus?
The I2S bus is configured to run on 44100Hz
but due to prescalers and external xtal frequency i can only get an
actual SR of 44002.75Hz SR

so when i generate a waveform of 440Hz it is nearly a multiple of the SR
my audio codec is running on.

julian


At each cycle start the he value of phase will be different. The
pattern of different waveforms will repeat at the rate of the LCM of
phaseInc and TABLESIZE.

Usually you would use a fixed point phase accumulator and phase
increment so you can have subsample accurate increment. That won't
change the fact that frequencies that don't have an integer-sample
period will look different each cycle.

Ross.



On 9/04/2012 11:28 PM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and
add it to phase
if(phase >= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played fine.
but as soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the overtones
about 2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone
frequency, the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some
ringing on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw
wavetable. but the flutter is the same, no matter if i use a bandlimited
WT or output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter.
but i can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book
reviews, dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp



--
... http://artbots.org
.douglas.irving http://dorkbot.org
.. http://music.columbia.edu/cmc/music-dsp
...repetto. http://music.columbia.edu/organism
... http://music.columbia.edu/~douglas

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread douglas repetto


Nope!

On 4/9/12 6:14 PM, douglas repetto wrote:


Just a test reply to see if I have the same problem Robert's having...

douglas

On 4/9/12 10:43 AM, Julian Schmidt wrote:

Am 09.04.2012 16:24, schrieb Ross Bencina:

Hello Julian,

Assuming all variables are integers, if phase doesn't divide TABLESIZE
then you will get a different waveform amplutude for adjacent cycles.
Perhaps that's what you're seeing?


oh sorry, i forgot to mention.

the phase accumulator is a float.
as well as the phaseIncrement value.

I know that my waveform will start on different amplitudes, but the
effect i'm hearing is very audible.
like a "click" noise about 2-3 times a second.
the root frequency is unaffected, around 10kHz it's a 6dB drop in
frequency, at 20kHz its allready12dB.
the error from the floating point phase wrapping shouldn't be THAT
audible.

what confuses me is that i coded a lot of wavetable OSCs on PCand never
had any problems with phase wrap noise.

maybe it's a problem related to the hardware... I'm new to the cortex m4.
could it have to do with a frequency error on the I2S bus?
The I2S bus is configured to run on 44100Hz
but due to prescalers and external xtal frequency i can only get an
actual SR of 44002.75Hz SR

so when i generate a waveform of 440Hz it is nearly a multiple of the SR
my audio codec is running on.

julian


At each cycle start the he value of phase will be different. The
pattern of different waveforms will repeat at the rate of the LCM of
phaseInc and TABLESIZE.

Usually you would use a fixed point phase accumulator and phase
increment so you can have subsample accurate increment. That won't
change the fact that frequencies that don't have an integer-sample
period will look different each cycle.

Ross.



On 9/04/2012 11:28 PM, Julian Schmidt wrote:

Hello all,

I'm trying to get an oscillator running on the STM32F4 discovery board.
I'm sending my audio with 44100Hz via I2S to the onboard codec.
However I'm experiencing strange problems.

my code ist quite straight forward:

phase += phaseInc(440); // calculate the phase increment for 440 hz and
add it to phase
if(phase >= TABLESIZE) phase -= TABLESIZE;
return phase/TABLESIZE;

this should give me a non bw limited saw from 0 to 1.f
(I also tried it with an actual wavetable in use. a sine is played
fine.
but as soon as overtones are added i get the fluttering)

My problem is that i get periodic amplitude modulations on the
overtones
about 2-3 times a second.
the root frequency amplitude is fixed, but the higher the overtone
frequency, the more it's amplitude drops every now and then.
this screenshot illustrates the waveform. the upper waveform has some
ringing on the discontinuity and the lower has not.
http://i.imgur.com/JyuEr.png (this image is taken from an inverted saw
wavetable. but the flutter is the same, no matter if i use a
bandlimited
WT or output the phase counter directly)
the waveform oscillates between the upper and the lower image.

the amplitude flutter from the overtones is also frequency dependent.
at 439 and 441 Hz its not really audible.

so my tought is that is has to do with the wrap of the phase counter.
but i can't get my head around whats wrong.
any ideas where this change in overtone amplitude could come from?

cheers,
julian






--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book
reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book
reviews, dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews,
dsp links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp





--
... http://artbots.org
.douglas.irving http://dorkbot.org
.. http://music.columbia.edu/cmc/music-dsp
...repetto. http://music.columbia.edu/organism
... http://music.columbia.edu/~douglas

--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


[music-dsp] testing different subject header

2012-04-09 Thread robert bristow-johnson


testing 1,2,3...

this is identical to a previous message (that would not get past my 
SMTP) with this sentence added and the subject header changed..


On 4/9/12 5:25 PM, Julian Schmidt wrote:

Am 09.04.2012 23:22, schrieb Olli Niemitalo:

On Mon, Apr 9, 2012 at 11:32 PM, Julian Schmidt
  wrote:

I really think it is an aliasing problem.
but not due to the wrong wavetable content, but due to a cheap audio 
codec

with poor filters.
[...]
even when i output a single 440hz sine i get harmonics starting at 
-48db up

to nyquist and beyond.

Lemme guess your wavetable size is 256? That's the amount of
distortion that would be expected from using "no interpolation". If
that's what you have then the codec is not at fault.


i use code similar to what RBJ has posted with linear interpolation 
(although with a tablesize of 256 at the moment).


julian


-olli
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book 
reviews, dsp links

http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book 
reviews, dsp links

http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp





--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] OSC problem on STM32F4Discovery

2012-04-09 Thread Gwenhwyfaer
It might be an idea to remove the codec from the equation. How about
if, rather than send the audio you're generating through the codec,
you store it as raw audio or a WAV file instead, and then drag it back
to the PC and see how it sounds through a known-good codec?
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp