Csound Csound-dev Csound-tekno Search About

[Csnd] output amplitude?

Date2021-03-27 15:49
FromTom Peters
Subject[Csnd] output amplitude?
Hi,
I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
Any problem with my code?
Thanx.

http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm

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

Date2021-03-27 16:04
FromDave Seidel
SubjectRe: [Csnd] output amplitude?
It looks like you are specifying 1.2 seconds for the madsr envelope (adding the segment values together), but the score only allows 1 second for each note, so this may have something to do with it.

BTW, I use pure tunings all the time (often using sines -- in fact I have a CD-length piece that uses nothing but since waves with pure tunings[1]) and have not noticed any variation in amplitude based on pitch. However, I use a higher-quality oscillator opcode (poscil3) which I would recommend for this sort of application, and perhaps this is a factor as well, though it seems less likely to me than the envelope.

I note that I haven't used masdr myself; for my purposes a simple AR envelope (e.g., using linen) is generally sufficient), but of course it depends on context which is the better choice.

- Dave


On Sat, Mar 27, 2021 at 11:49 AM Tom Peters <tpeters@telfort.nl> wrote:
Hi,
I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
Any problem with my code?
Thanx.

http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm

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

Date2021-03-27 16:12
FromDave Seidel
SubjectRe: [Csnd] output amplitude?
Oops: "since waves" shou;d be "sine waves".

On Sat, Mar 27, 2021 at 12:04 PM Dave Seidel <dave.seidel@gmail.com> wrote:
It looks like you are specifying 1.2 seconds for the madsr envelope (adding the segment values together), but the score only allows 1 second for each note, so this may have something to do with it.

BTW, I use pure tunings all the time (often using sines -- in fact I have a CD-length piece that uses nothing but since waves with pure tunings[1]) and have not noticed any variation in amplitude based on pitch. However, I use a higher-quality oscillator opcode (poscil3) which I would recommend for this sort of application, and perhaps this is a factor as well, though it seems less likely to me than the envelope.

I note that I haven't used masdr myself; for my purposes a simple AR envelope (e.g., using linen) is generally sufficient), but of course it depends on context which is the better choice.

- Dave


On Sat, Mar 27, 2021 at 11:49 AM Tom Peters <tpeters@telfort.nl> wrote:
Hi,
I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
Any problem with my code?
Thanx.

http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm

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

Date2021-03-27 16:28
FromBill Alves
SubjectRe: [Csnd] output amplitude?
I think that madsr is not a problem. If you look at the rendered output file:

https://drive.google.com/file/d/1L33t9fYrwRjpp12WvwplpGhcf0MSnUuj/view?usp=sharing

you can see that all the notes are exactly the same amplitude. Any subjective change in loudness is because of psychoacoustic factors. There’s no problem with the code.

I also enjoy tinkering with Csound for study of harmony and tuning.

Bill

> On Sat, Mar 27, 2021 at 11:49 AM Tom Peters  wrote:
> Hi,
> I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
> Any problem with my code?
> Thanx.
> 
> http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm
> 
> 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

Bill Alves
Professor of Music, The Claremont Colleges
Harvey Mudd College
301 Platt Blvd. Claremont CA 91711
http://pages.hmc.edu/alves/
http://www.billalves.com/

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

Date2021-03-27 16:30
FromDave Seidel
SubjectRe: [Csnd] output amplitude?
Thanks, Bill, I should have considered that aspect!

On Sat, Mar 27, 2021 at 12:28 PM Bill Alves <alves@g.hmc.edu> wrote:
I think that madsr is not a problem. If you look at the rendered output file:

https://drive.google.com/file/d/1L33t9fYrwRjpp12WvwplpGhcf0MSnUuj/view?usp=sharing

you can see that all the notes are exactly the same amplitude. Any subjective change in loudness is because of psychoacoustic factors. There’s no problem with the code.

I also enjoy tinkering with Csound for study of harmony and tuning.

Bill

> On Sat, Mar 27, 2021 at 11:49 AM Tom Peters <tpeters@telfort.nl> wrote:
> Hi,
> I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
> Any problem with my code?
> Thanx.
>
> http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm
>
> 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

Bill Alves
Professor of Music, The Claremont Colleges
Harvey Mudd College
301 Platt Blvd. Claremont CA 91711
http://pages.hmc.edu/alves/
http://www.billalves.com/

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

Date2021-03-27 16:36
FromJohn ff
SubjectRe: [Csnd] output amplitude?
Just a suggestion. Try modifying the amplitude with a sone table. That is supposed to account for psycho effects

On 27 Mar 2021, at 15:50, Tom Peters <tpeters@telfort.nl> wrote:
Hi,
I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines. I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
Any problem with my code?
Thanx.

http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm

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

Date2021-03-29 08:41
FromTom Peters
SubjectRe: [Csnd] output amplitude?
Bill,
thank you for making the diagram. What do you use to convert a .ogg file 
to a graph?
All my notes are programmed to play for 1 second, but from the graph I 
see that they are not neatly separated but blend one into the other, 
showing beat frequencies. Only the last note tapers off as I intended. 
So Dave Seidel may be right that somehow the envelope stretches each 
note to 1.2 seconds.
Any idea what might be going on, or how the madsr should be used?
-- 
Tom Peters

On 27-03-2021 17:28, Bill Alves wrote:
> I think that madsr is not a problem. If you look at the rendered output file:
> 
> https://drive.google.com/file/d/1L33t9fYrwRjpp12WvwplpGhcf0MSnUuj/view?usp=sharing
> 
> you can see that all the notes are exactly the same amplitude. Any subjective change in loudness is because of psychoacoustic factors. There’s no problem with the code.
> 
> I also enjoy tinkering with Csound for study of harmony and tuning.
> 
> Bill
> 
>> On Sat, Mar 27, 2021 at 11:49 AM Tom Peters  wrote:
>> Hi,
>> I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
>> Any problem with my code?
>> Thanx.
>>
>> http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm
>>
>> 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
> 
> Bill Alves
> Professor of Music, The Claremont Colleges
> Harvey Mudd College
> 301 Platt Blvd. Claremont CA 91711
> http://pages.hmc.edu/alves/
> http://www.billalves.com/
> 
> 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

Date2021-03-29 17:40
FromPete Goodeve
SubjectRe: [Csnd] output amplitude?
AttachmentsNone  

Date2021-03-29 18:15
FromBill Alves
SubjectRe: [Csnd] output amplitude?
Dear Tom,

I just looked at the audio file within an audio editor. I use Amadeus but one can also use Audacity or any number of others. By the way, one can choose the format of the output file, and it does not have to be in ogg format, in case your audio editor will not open ogg files.

As Pete mentioned, madsr adds the release segment onto the end of the specified note duration (p3). This is so that, when used with MIDI, the release segment is added on after the note-off message. The opcode adsr may act like you expect. 

Because the notes are only a step apart, you will see and hear beat frequencies when they overlap.

Bill

> On Mar 29, 2021, at 12:41 AM, Tom Peters  wrote:
> 
> Bill,
> thank you for making the diagram. What do you use to convert a .ogg file to a graph?
> All my notes are programmed to play for 1 second, but from the graph I see that they are not neatly separated but blend one into the other, showing beat frequencies. Only the last note tapers off as I intended. So Dave Seidel may be right that somehow the envelope stretches each note to 1.2 seconds.
> Any idea what might be going on, or how the madsr should be used?
> -- 
> Tom Peters
> 
> On 27-03-2021 17:28, Bill Alves wrote:
>> I think that madsr is not a problem. If you look at the rendered output file:
>> https://drive.google.com/file/d/1L33t9fYrwRjpp12WvwplpGhcf0MSnUuj/view?usp=sharing
>> you can see that all the notes are exactly the same amplitude. Any subjective change in loudness is because of psychoacoustic factors. There’s no problem with the code.
>> I also enjoy tinkering with Csound for study of harmony and tuning.
>> Bill
>>> On Sat, Mar 27, 2021 at 11:49 AM Tom Peters  wrote:
>>> Hi,
>>> I've been tinkering with CSound for study of hamony and tuning. One of the problems I am having is that the volume of sound output appears uneven. For example check this page: the diatonic ladder in E in Pythagorean tuning playing pure sines.  I specify the frequencies as fractions w.r.t. a base frequency (i.c. 440 Hz). To me the higher frequency tones appear fainter than lower frequency tones, and the note with base frequency appears louder than all. But for the amplitude I used the same iAmp=0.25 for all notes.
>>> Any problem with my code?
>>> Thanx.
>>> 
>>> http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm
>>> 
>>> 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
>> Bill Alves
>> Professor of Music, The Claremont Colleges
>> Harvey Mudd College
>> 301 Platt Blvd. Claremont CA 91711
>> http://pages.hmc.edu/alves/
>> http://www.billalves.com/
>> 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

Bill Alves
Professor of Music, The Claremont Colleges
Harvey Mudd College
301 Platt Blvd. Claremont CA 91711
http://pages.hmc.edu/alves/
http://www.billalves.com/

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

Date2021-03-29 18:58
FromJohn ff
SubjectRe: [Csnd] output amplitude?
madsr was designed for use with midi.  You might find adsr more like what you want.
On 29 Mar 2021, at 17:41, Pete Goodeve <pete.goodeve@computer.org> wrote:
On Mon, Mar 29, 2021 at 09:41:16AM +0200, Tom Peters wrote:
Bill,
thank you for making the diagram. What do you use to convert a .ogg file
to a graph?
I guess that depends on your OS. I used a utility on the Haiku OS I run,
and can verify Bill's statements. I can also verify that there is a considerable
subjective variation in the amplitudes of the sequence when listening!
I'm not sure if it's resonance in my audio or what, but the first of your
sounds seems much louder than the others. To check that this wasn't
a "first one" effect, I added in the [64/81] sound at the start (which is much
softer to me), and the "440 [3/2]" tone is still the (subjective) loudest.

OK, I just used headphones from my laptop audio, and the effect is the same.
Guess it's my ears! If I just use the laptop's own (tinny!) speakers, the effect
is very pronounced. Can hardly hear the later notes.

All my notes are programmed to play for 1 second, but from the graph I
see that they are not neatly separated but blend one into the other,
showing beat frequencies. Only the last note tapers off as I intended.
So Dave Seidel may be right that somehow the envelope stretches each
note to 1.2 seconds.

Yes, as I understand it, that's how madsr works. The release time is *added on*
to the p3 of the note. The madsr page is not very clear, but it says it uses 'linsegr'
and that page says:
"When [it] senses an event termination or MIDI noteoff, it immediately extends
the performance time of the current instrument by irel seconds, and sets out to
reach the value iz by the end of that period (no matter which segment the unit is in"

Any idea what might be going on, or how the madsr should be used?

I just changed all notes in the score except the first to:
i 1 ^+1.5 . 440 [4/3]
etc.
(I.e. replaced "+" with "^+1.5", so the notes are 1.5 secs apart, but still
only 1 second long.) No beat frequencies now, but the effect is still there.

-- Pete --

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

Date2021-03-31 10:26
FromTom Peters
SubjectRe: [Csnd] output amplitude?
Bill, John,
thanx for the tips.
For those interested, you may find the final (for now) version for the 
Pythagorean scale here:
http://arpeters.net/Nederlandse_paginas/Muziekleer/PytEAE.htm
-- 
Tom

On 29-03-2021 19:58, John ff wrote:
> madsr was designed for use with midi.  You might find adsr more like 
> what you want.
> Get TypeApp for Android 
> On 29 Mar 2021, at 17:41, Pete Goodeve  > wrote:
> 
>     On Mon, Mar 29, 2021 at 09:41:16AM +0200, Tom Peters wrote:
> 
>         Bill,
>         thank you for making the diagram. What do you use to convert a
>         .ogg file
>         to a graph?
> 
>     I guess that depends on your OS.  I used a utility on the Haiku OS I run,
>     and can verify Bill's statements.  I can also verify that there is a considerable
>     subjective variation in the amplitudes of the sequence when listening!
>     I'm not sure if it's resonance in my audio or what, but the first of your
>     sounds seems much louder than the others.  To check that this wasn't
>     a "first one" effect, I added in the [64/81] sound at the start (which is much
>     softer to me), and the "440 [3/2]" tone is still the (subjective) loudest.
> 
>     OK, I just used headphones from my laptop audio, and the effect is the same.
>     Guess it's my ears!  If I just use the laptop's own (tinny!) speakers, the effect
>     is very pronounced.  Can hardly hear the later notes.
> 
>         All my notes are programmed to play for 1 second, but from the
>         graph I
>         see that they are not neatly separated but blend one into the
>         other,
>         showing beat frequencies. Only the last note tapers off as I
>         intended.
>         So Dave Seidel may be right that somehow the envelope stretches
>         each
>         note to 1.2 seconds.
> 
> 
>     Yes, as I understand it, that's how madsr works.  The release time is *added on*
>     to the p3 of the note. The madsr page is not very clear, but it says it uses 'linsegr'
>     and that page says:
>     "When [it] senses an event termination or MIDI noteoff, it immediately extends
>     the performance time of the current instrument by irel seconds, and sets out to
>     reach the value iz by the end of that period (no matter which segment the unit is in"
> 
>         Any idea what might be going on, or how the madsr should be used?
> 
> 
>     I just changed all notes in the score except the first to:
>            i 1 ^+1.5 . 440 [4/3]
>     etc.
>       (I.e. replaced "+" with "^+1.5", so the notes are 1.5 secs apart, but still
>     only 1 second long.)  No beat frequencies now, but the effect is still there.
> 
>       -- Pete --
> 
>     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