Csound Csound-dev Csound-tekno Search About

Brown Noise

Date2015-12-30 23:48
FromSteven Yi
SubjectBrown Noise
AttachmentsBrown_Noise.csd  
Hi All,

I was curious about Brown Noise and wondered if there was anything
already in Csound.  The one thing I found was the fractalnoise opcode
that supports brown noise through its filter bank.  I wrote a simple
brown noise UDO based on information in [1]:

sr=44100
ksmps=32
nchnls=2
0dbfs=1

opcode brown_noise, a, 0

kval init random:i(-1, 1)
aout init 0
asig = random:a(-0.1, 0.1)
kndx = 0

until (kndx >= ksmps) do
  kval = mirror((kval + asig[kndx]), -1.0, 1.0)
  aout[kndx] = kval
  kndx += 1
od

xout aout

endop

that sounds about right to me (I did not do measurements or plotting,
however).  I assume mirroring on [-1.0,1.0] is correct, and using
[-0.1,0.1] for the white noise for integration sounded about right.

If someone has experience with brown noise could verify that the above
is correct or if there is another built-in option besides
fractalnoise, I'd love to know.

Thanks!
steven




[1] - https://en.wikipedia.org/wiki/Brownian_noise

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2015-12-31 12:38
FromAnton Kholomiov
SubjectRe: Brown Noise

I guess we can achieve the same result by integration of white noise.
We can compose:

brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1

Anton


2015-12-31 2:48 GMT+03:00 Steven Yi <stevenyi@gmail.com>:
Hi All,

I was curious about Brown Noise and wondered if there was anything
already in Csound.  The one thing I found was the fractalnoise opcode
that supports brown noise through its filter bank.  I wrote a simple
brown noise UDO based on information in [1]:

sr=44100
ksmps=32
nchnls=2
0dbfs=1

opcode brown_noise, a, 0

kval init random:i(-1, 1)
aout init 0
asig = random:a(-0.1, 0.1)
kndx = 0

until (kndx >= ksmps) do
  kval = mirror((kval + asig[kndx]), -1.0, 1.0)
  aout[kndx] = kval
  kndx += 1
od

xout aout

endop

that sounds about right to me (I did not do measurements or plotting,
however).  I assume mirroring on [-1.0,1.0] is correct, and using
[-0.1,0.1] for the white noise for integration sounded about right.

If someone has experience with brown noise could verify that the above
is correct or if there is another built-in option besides
fractalnoise, I'd love to know.

Thanks!
steven




[1] - https://en.wikipedia.org/wiki/Brownian_noise

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 12:39
FromAnton Kholomiov
SubjectRe: Brown Noise
Only I forget to put he commas between arguments..

2015-12-31 15:38 GMT+03:00 Anton Kholomiov <anton.kholomiov@gmail.com>:

I guess we can achieve the same result by integration of white noise.
We can compose:

brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1

Anton


2015-12-31 2:48 GMT+03:00 Steven Yi <stevenyi@gmail.com>:
Hi All,

I was curious about Brown Noise and wondered if there was anything
already in Csound.  The one thing I found was the fractalnoise opcode
that supports brown noise through its filter bank.  I wrote a simple
brown noise UDO based on information in [1]:

sr=44100
ksmps=32
nchnls=2
0dbfs=1

opcode brown_noise, a, 0

kval init random:i(-1, 1)
aout init 0
asig = random:a(-0.1, 0.1)
kndx = 0

until (kndx >= ksmps) do
  kval = mirror((kval + asig[kndx]), -1.0, 1.0)
  aout[kndx] = kval
  kndx += 1
od

xout aout

endop

that sounds about right to me (I did not do measurements or plotting,
however).  I assume mirroring on [-1.0,1.0] is correct, and using
[-0.1,0.1] for the white noise for integration sounded about right.

If someone has experience with brown noise could verify that the above
is correct or if there is another built-in option besides
fractalnoise, I'd love to know.

Thanks!
steven




[1] - https://en.wikipedia.org/wiki/Brownian_noise

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 12:54
FromAnton Kholomiov
SubjectRe: Brown Noise

Also it’s good to put dcblock as the last statement. Here is my take on the task:

a1 white_noise
a2 integ (0.005 * a1)
a1 mirror a2, -0.5, 0.5
a2 dcblock a1
xout  (2 * a2)

2015-12-31 15:39 GMT+03:00 Anton Kholomiov <anton.kholomiov@gmail.com>:
Only I forget to put he commas between arguments..

2015-12-31 15:38 GMT+03:00 Anton Kholomiov <anton.kholomiov@gmail.com>:

I guess we can achieve the same result by integration of white noise.
We can compose:

brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1

Anton


2015-12-31 2:48 GMT+03:00 Steven Yi <stevenyi@gmail.com>:
Hi All,

I was curious about Brown Noise and wondered if there was anything
already in Csound.  The one thing I found was the fractalnoise opcode
that supports brown noise through its filter bank.  I wrote a simple
brown noise UDO based on information in [1]:

sr=44100
ksmps=32
nchnls=2
0dbfs=1

opcode brown_noise, a, 0

kval init random:i(-1, 1)
aout init 0
asig = random:a(-0.1, 0.1)
kndx = 0

until (kndx >= ksmps) do
  kval = mirror((kval + asig[kndx]), -1.0, 1.0)
  aout[kndx] = kval
  kndx += 1
od

xout aout

endop

that sounds about right to me (I did not do measurements or plotting,
however).  I assume mirroring on [-1.0,1.0] is correct, and using
[-0.1,0.1] for the white noise for integration sounded about right.

If someone has experience with brown noise could verify that the above
is correct or if there is another built-in option besides
fractalnoise, I'd love to know.

Thanks!
steven




[1] - https://en.wikipedia.org/wiki/Brownian_noise

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here



Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 15:25
FromSteven Yi
SubjectRe: Brown Noise
Hi Anton,

Thanks for the reply!  There's a couple things I wanted to comment on:

1. For the white noise, I was wondering whether to use a range of
[-0.05,0.05] or [-0.1, 0.1]. The article mentioned 0.1 but it seemed a
bit ambiguous.  I may switch to [-0.05, 0.05] but see you are using
[-0.005, 0.005].  Any particular reason for those values?

2. I also thought about using integ, but I was worried about the
signal accumulating and potentially growing largely outside the bounds
of the mirror.  In those cases, the a-rate mirror opcode would have to
do extra passes to get it within the bounds. My thought with doing it
sample-by-sample was to keep it within the bounds and limit the
mirror's processing to a single-pass. This might be a premature
optimization though, and using integ is certainly easier to read.

3. The use of dcblock is interesting. I see the 2 * a2 and mirror with
bounds [-0.5,0.5].  I'm curious, why not just use [-1.0, 1.0] and skip
the scaling?

Thanks!
steven

On Thu, Dec 31, 2015 at 7:54 AM, Anton Kholomiov
 wrote:
> Also it’s good to put dcblock as the last statement. Here is my take on the
> task:
>
> a1 white_noise
> a2 integ (0.005 * a1)
> a1 mirror a2, -0.5, 0.5
> a2 dcblock a1
> xout  (2 * a2)
>
>
> 2015-12-31 15:39 GMT+03:00 Anton Kholomiov :
>>
>> Only I forget to put he commas between arguments..
>>
>> 2015-12-31 15:38 GMT+03:00 Anton Kholomiov :
>>>
>>> I guess we can achieve the same result by integration of white noise.
>>> We can compose:
>>>
>>> brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1
>>>
>>> Anton
>>>
>>>
>>> 2015-12-31 2:48 GMT+03:00 Steven Yi :
>>>>
>>>> Hi All,
>>>>
>>>> I was curious about Brown Noise and wondered if there was anything
>>>> already in Csound.  The one thing I found was the fractalnoise opcode
>>>> that supports brown noise through its filter bank.  I wrote a simple
>>>> brown noise UDO based on information in [1]:
>>>>
>>>> sr=44100
>>>> ksmps=32
>>>> nchnls=2
>>>> 0dbfs=1
>>>>
>>>> opcode brown_noise, a, 0
>>>>
>>>> kval init random:i(-1, 1)
>>>> aout init 0
>>>> asig = random:a(-0.1, 0.1)
>>>> kndx = 0
>>>>
>>>> until (kndx >= ksmps) do
>>>>   kval = mirror((kval + asig[kndx]), -1.0, 1.0)
>>>>   aout[kndx] = kval
>>>>   kndx += 1
>>>> od
>>>>
>>>> xout aout
>>>>
>>>> endop
>>>>
>>>> that sounds about right to me (I did not do measurements or plotting,
>>>> however).  I assume mirroring on [-1.0,1.0] is correct, and using
>>>> [-0.1,0.1] for the white noise for integration sounded about right.
>>>>
>>>> If someone has experience with brown noise could verify that the above
>>>> is correct or if there is another built-in option besides
>>>> fractalnoise, I'd love to know.
>>>>
>>>> Thanks!
>>>> steven
>>>>
>>>>
>>>>
>>>>
>>>> [1] - https://en.wikipedia.org/wiki/Brownian_noise
>>>>
>>>> Csound mailing list
>>>> Csound@listserv.heanet.ie
>>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>>> Send bugs reports to
>>>>         https://github.com/csound/csound/issues
>>>> Discussions of bugs and features can be posted here
>>>
>>>
>>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2015-12-31 15:38
FromAnton Kholomiov
SubjectRe: Brown Noise
I'm sorry there is no scientific background for those choices
I've tried different constants and listened to the output. 
Some of them seem more close to the clip that I've found on the web.
The 

on those -0.5 to 0.5. I think it's better to set it to -1 to 1 interval.
I've reduced it to -0.5 to 0.5 because with -1 to 1 I get strange
interrupts in the noise wave. It wasn't continuous wall of the sound.
There were some falls in the amplitude volume. But dcblock fixes
that. So I've re-listened to the new version with dcblock on and -1 to 1
and it sounds the same as -0.5 to 0.5.

Well actually the 0.005 choice was due to that same problem with noise interrupts.
But I've retried it with 0.1 and 0.05 the sound becomes much brighter.
And there is no interrupts due to dcblock is turned on.
So I guess it's best to choose 0.1 or 0.05 indeed!

Cheers,
Anton

2015-12-31 18:25 GMT+03:00 Steven Yi <stevenyi@gmail.com>:
Hi Anton,

Thanks for the reply!  There's a couple things I wanted to comment on:

1. For the white noise, I was wondering whether to use a range of
[-0.05,0.05] or [-0.1, 0.1]. The article mentioned 0.1 but it seemed a
bit ambiguous.  I may switch to [-0.05, 0.05] but see you are using
[-0.005, 0.005].  Any particular reason for those values?

2. I also thought about using integ, but I was worried about the
signal accumulating and potentially growing largely outside the bounds
of the mirror.  In those cases, the a-rate mirror opcode would have to
do extra passes to get it within the bounds. My thought with doing it
sample-by-sample was to keep it within the bounds and limit the
mirror's processing to a single-pass. This might be a premature
optimization though, and using integ is certainly easier to read.

3. The use of dcblock is interesting. I see the 2 * a2 and mirror with
bounds [-0.5,0.5].  I'm curious, why not just use [-1.0, 1.0] and skip
the scaling?

Thanks!
steven

On Thu, Dec 31, 2015 at 7:54 AM, Anton Kholomiov
<anton.kholomiov@gmail.com> wrote:
> Also it’s good to put dcblock as the last statement. Here is my take on the
> task:
>
> a1 white_noise
> a2 integ (0.005 * a1)
> a1 mirror a2, -0.5, 0.5
> a2 dcblock a1
> xout  (2 * a2)
>
>
> 2015-12-31 15:39 GMT+03:00 Anton Kholomiov <anton.kholomiov@gmail.com>:
>>
>> Only I forget to put he commas between arguments..
>>
>> 2015-12-31 15:38 GMT+03:00 Anton Kholomiov <anton.kholomiov@gmail.com>:
>>>
>>> I guess we can achieve the same result by integration of white noise.
>>> We can compose:
>>>
>>> brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1
>>>
>>> Anton
>>>
>>>
>>> 2015-12-31 2:48 GMT+03:00 Steven Yi <stevenyi@gmail.com>:
>>>>
>>>> Hi All,
>>>>
>>>> I was curious about Brown Noise and wondered if there was anything
>>>> already in Csound.  The one thing I found was the fractalnoise opcode
>>>> that supports brown noise through its filter bank.  I wrote a simple
>>>> brown noise UDO based on information in [1]:
>>>>
>>>> sr=44100
>>>> ksmps=32
>>>> nchnls=2
>>>> 0dbfs=1
>>>>
>>>> opcode brown_noise, a, 0
>>>>
>>>> kval init random:i(-1, 1)
>>>> aout init 0
>>>> asig = random:a(-0.1, 0.1)
>>>> kndx = 0
>>>>
>>>> until (kndx >= ksmps) do
>>>>   kval = mirror((kval + asig[kndx]), -1.0, 1.0)
>>>>   aout[kndx] = kval
>>>>   kndx += 1
>>>> od
>>>>
>>>> xout aout
>>>>
>>>> endop
>>>>
>>>> that sounds about right to me (I did not do measurements or plotting,
>>>> however).  I assume mirroring on [-1.0,1.0] is correct, and using
>>>> [-0.1,0.1] for the white noise for integration sounded about right.
>>>>
>>>> If someone has experience with brown noise could verify that the above
>>>> is correct or if there is another built-in option besides
>>>> fractalnoise, I'd love to know.
>>>>
>>>> Thanks!
>>>> steven
>>>>
>>>>
>>>>
>>>>
>>>> [1] - https://en.wikipedia.org/wiki/Brownian_noise
>>>>
>>>> Csound mailing list
>>>> Csound@listserv.heanet.ie
>>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>>> Send bugs reports to
>>>>         https://github.com/csound/csound/issues
>>>> Discussions of bugs and features can be posted here
>>>
>>>
>>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2015-12-31 17:28
FromSteven Yi
SubjectRe: Brown Noise
Thanks for taking the time to explain that, it's always informative to
hear the reasoning and the process behind these decisions.  I'll have
to test and research further (I certainly want to read those
references for fractalnoise!), but at least it's good to get a decent
brown noise already.

All best!
steven


On Thu, Dec 31, 2015 at 10:38 AM, Anton Kholomiov
 wrote:
> I'm sorry there is no scientific background for those choices
> I've tried different constants and listened to the output.
> Some of them seem more close to the clip that I've found on the web.
> The
>
> on those -0.5 to 0.5. I think it's better to set it to -1 to 1 interval.
> I've reduced it to -0.5 to 0.5 because with -1 to 1 I get strange
> interrupts in the noise wave. It wasn't continuous wall of the sound.
> There were some falls in the amplitude volume. But dcblock fixes
> that. So I've re-listened to the new version with dcblock on and -1 to 1
> and it sounds the same as -0.5 to 0.5.
>
> Well actually the 0.005 choice was due to that same problem with noise
> interrupts.
> But I've retried it with 0.1 and 0.05 the sound becomes much brighter.
> And there is no interrupts due to dcblock is turned on.
> So I guess it's best to choose 0.1 or 0.05 indeed!
>
> Cheers,
> Anton
>
> 2015-12-31 18:25 GMT+03:00 Steven Yi :
>>
>> Hi Anton,
>>
>> Thanks for the reply!  There's a couple things I wanted to comment on:
>>
>> 1. For the white noise, I was wondering whether to use a range of
>> [-0.05,0.05] or [-0.1, 0.1]. The article mentioned 0.1 but it seemed a
>> bit ambiguous.  I may switch to [-0.05, 0.05] but see you are using
>> [-0.005, 0.005].  Any particular reason for those values?
>>
>> 2. I also thought about using integ, but I was worried about the
>> signal accumulating and potentially growing largely outside the bounds
>> of the mirror.  In those cases, the a-rate mirror opcode would have to
>> do extra passes to get it within the bounds. My thought with doing it
>> sample-by-sample was to keep it within the bounds and limit the
>> mirror's processing to a single-pass. This might be a premature
>> optimization though, and using integ is certainly easier to read.
>>
>> 3. The use of dcblock is interesting. I see the 2 * a2 and mirror with
>> bounds [-0.5,0.5].  I'm curious, why not just use [-1.0, 1.0] and skip
>> the scaling?
>>
>> Thanks!
>> steven
>>
>> On Thu, Dec 31, 2015 at 7:54 AM, Anton Kholomiov
>>  wrote:
>> > Also it’s good to put dcblock as the last statement. Here is my take on
>> > the
>> > task:
>> >
>> > a1 white_noise
>> > a2 integ (0.005 * a1)
>> > a1 mirror a2, -0.5, 0.5
>> > a2 dcblock a1
>> > xout  (2 * a2)
>> >
>> >
>> > 2015-12-31 15:39 GMT+03:00 Anton Kholomiov :
>> >>
>> >> Only I forget to put he commas between arguments..
>> >>
>> >> 2015-12-31 15:38 GMT+03:00 Anton Kholomiov :
>> >>>
>> >>> I guess we can achieve the same result by integration of white noise.
>> >>> We can compose:
>> >>>
>> >>> brown_noise = mirror (integ (0.005 * white_noise)) (-1) 1
>> >>>
>> >>> Anton
>> >>>
>> >>>
>> >>> 2015-12-31 2:48 GMT+03:00 Steven Yi :
>> >>>>
>> >>>> Hi All,
>> >>>>
>> >>>> I was curious about Brown Noise and wondered if there was anything
>> >>>> already in Csound.  The one thing I found was the fractalnoise opcode
>> >>>> that supports brown noise through its filter bank.  I wrote a simple
>> >>>> brown noise UDO based on information in [1]:
>> >>>>
>> >>>> sr=44100
>> >>>> ksmps=32
>> >>>> nchnls=2
>> >>>> 0dbfs=1
>> >>>>
>> >>>> opcode brown_noise, a, 0
>> >>>>
>> >>>> kval init random:i(-1, 1)
>> >>>> aout init 0
>> >>>> asig = random:a(-0.1, 0.1)
>> >>>> kndx = 0
>> >>>>
>> >>>> until (kndx >= ksmps) do
>> >>>>   kval = mirror((kval + asig[kndx]), -1.0, 1.0)
>> >>>>   aout[kndx] = kval
>> >>>>   kndx += 1
>> >>>> od
>> >>>>
>> >>>> xout aout
>> >>>>
>> >>>> endop
>> >>>>
>> >>>> that sounds about right to me (I did not do measurements or plotting,
>> >>>> however).  I assume mirroring on [-1.0,1.0] is correct, and using
>> >>>> [-0.1,0.1] for the white noise for integration sounded about right.
>> >>>>
>> >>>> If someone has experience with brown noise could verify that the
>> >>>> above
>> >>>> is correct or if there is another built-in option besides
>> >>>> fractalnoise, I'd love to know.
>> >>>>
>> >>>> Thanks!
>> >>>> steven
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> [1] - https://en.wikipedia.org/wiki/Brownian_noise
>> >>>>
>> >>>> Csound mailing list
>> >>>> Csound@listserv.heanet.ie
>> >>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> >>>> Send bugs reports to
>> >>>>         https://github.com/csound/csound/issues
>> >>>> Discussions of bugs and features can be posted here
>> >>>
>> >>>
>> >>
>> >
>> > Csound mailing list Csound@listserv.heanet.ie
>> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> > https://github.com/csound/csound/issues Discussions of bugs and features
>> > can
>> > be posted here
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here