[Csnd] Scaling amplitude depending on number of instruments
Date | 2020-12-04 20:26 |
From | Jason Hallen |
Subject | [Csnd] Scaling amplitude depending on number of instruments |
Hi everyone,
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
I've made a music generator that outputs pieces of music with a user-defined number of instrumental parts. The number of instrumental parts is set at the beginning of the piece and doesn't change throughout the piece, though some instruments may be muted at various points. The amplitude of each instrument note is randomly selected from 0.1 to 0.9 and then divided by the total number of instrumental parts in the piece. I've also calibrated each instrument in the orchestra to stay under 0dbfs when played on its own. That's my crude attempt to scale the amplitudes depending on the number of instrumental parts. However, that doesn't seem like the smartest solution. The more instrumental parts in a piece, the quieter the overall piece gets because the parts are excessively scaled down. There's got to be a better way. Can you recommend better ways to scale instrument amplitude depending on the number of instrumental parts? Thanks! Jason |
Date | 2020-12-04 20:44 |
From | Justin Smith |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
the division you are doing will scale amplitude linearly, but the increase in magnitude is only linear if all notes are perfectly in tune and in phase at all times. I'd suggest, as an alternative, having a global variable for each "instrument group" (like an orchestra's section), with a simple curve formula to get the scaling factor for that group (someone else might have a good magic formula to offer here, but maybe something like 0.8^(instrument_count - 1) as a first stab?) 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 |
Date | 2020-12-04 20:46 |
From | john |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
I have heard it suggested that one should scale by sqrt(num_of_instruments) Might be worth a try..... On Fri, 4 Dec 2020, Jason Hallen wrote: > Hi everyone, > I've made a music generator that outputs pieces of music with a user-defined > number of instrumental parts. The number of instrumental parts is set at the > beginning of the piece and doesn't change throughout the piece, though some > instruments may be muted at various points. > > The amplitude of each instrument note is randomly selected from 0.1 to 0.9 and > then divided by the total number of instrumental parts in the piece. I've > also calibrated each instrument in the orchestra to stay under 0dbfs when > played on its own. > > That's my crude attempt to scale the amplitudes depending on the number of > instrumental parts. However, that doesn't seem like the smartest solution. > The more instrumental parts in a piece, the quieter the overall piece gets > because the parts are excessively scaled down. There's got to be a better > way. Can you recommend better ways to scale instrument amplitude depending on > the number of instrumental parts? > > Thanks! > Jason > 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 |
Date | 2020-12-04 21:15 |
From | john |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
You could use balance of the final ouput, balancing against a reference sound to give dynamics On Fri, 4 Dec 2020, Jason Hallen wrote: > Hi everyone, > I've made a music generator that outputs pieces of music with a user-defined > number of instrumental parts. The number of instrumental parts is set at the > beginning of the piece and doesn't change throughout the piece, though some > instruments may be muted at various points. > > The amplitude of each instrument note is randomly selected from 0.1 to 0.9 and > then divided by the total number of instrumental parts in the piece. I've > also calibrated each instrument in the orchestra to stay under 0dbfs when > played on its own. > > That's my crude attempt to scale the amplitudes depending on the number of > instrumental parts. However, that doesn't seem like the smartest solution. > The more instrumental parts in a piece, the quieter the overall piece gets > because the parts are excessively scaled down. There's got to be a better > way. Can you recommend better ways to scale instrument amplitude depending on > the number of instrumental parts? > > Thanks! > Jason > 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 |
Date | 2020-12-04 21:46 |
From | David Bellows |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
I had(/have) this exact same problem. I experimented around a lot, pretty much blindly since I don't understand what's going on with Csound nor with the math. Here is my current solution. It is written in Lua but forgive me as I don't really remember what it does or how it works. I'm a poor programmer but maybe you can figure it out: volume = volume * (1 / (math.log(number_of_instruments, 1.61803398875) +1)) The number 1.618... is the golden mean. So I think we're taking 1 over the log of the number of notes base golden mean. Hopefully there's something useful for you in that mess. As of now it is working well in my various test cases. Dave On Fri, Dec 4, 2020 at 1:16 PM john |
Date | 2020-12-05 00:49 |
From | thorin kerr |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
I've got a UDO which may help. ;asig activedamp asig ;reduces amplitude of an audio signal based on the number of currently active instruments. ;reduction is 3db every doubling of current instances. ;ktime smooths the changes to avoid clicks (defaults to 0.08 seconds) ;iinsnum is the instrument number to monitor (defaults to calling instrument p1. 0 monitors all instruments.) opcode activedamp, a,aOj asig, ktime, iinsnum xin setksmps 1 iinsnum = (iinsnum == -1 ? p1 : iinsnum) kampfac = ampdbfs(active:k(iinsnum, 0, 1)*-1.5); drop 3db every doubling. asig *= lineto(kampfac, limit:k(ktime, 0.008, 5)) xout asig endop Thorin On Sat, Dec 5, 2020 at 7:46 AM David Bellows <davebellows@gmail.com> wrote: I had(/have) this exact same problem. I experimented around a lot, |
Date | 2020-12-09 14:28 |
From | Jason Hallen |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
Thanks everybody for sharing solutions to this problem. I've tested them out and will go with Justin's equation for now. While working through this issue I also discovered a more fundamental error I had been making with instrument amplitudes, which I've also fixed. Now everything is working better. Thanks! Jason On Fri, Dec 4, 2020 at 6:50 PM thorin kerr <thorin.kerr@gmail.com> wrote:
|
Date | 2021-01-06 21:11 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
This is a request for another 'missing' opcode It would be great to have an opcode in Csound that does what thorin's UDO does. - dealing with amplitudes in a smart, intuitive, adaptive, and 'invisible' way would be great - much used, and useful. Maybe a new opcode could be added with this or other algorithms or options. Dr.B. Dr. Richard Boulanger Professor of Electronic Production and Design On Fri, Dec 4, 2020 at 7:50 PM thorin kerr <thorin.kerr@gmail.com> wrote:
|
Date | 2021-01-06 23:39 |
From | thorin kerr |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
Umm... on that UDO... I realised after posting that my formula was a bit off. This does better. ;reduces amplitude of an audio signal based on the number of currently active instruments. ;reduction is 3db every doubling of current instances. ;ktime smooths the changes to avoid clicks (defaults to 0.08 seconds) ;iinsnum is the instrument number to monitor (defaults to calling instrument p1. 0 monitors all instruments.) opcode activedamp, a,aOj asig, ktime, iinsnum xin setksmps 1 iinsnum = (iinsnum == -1 ? p1 : iinsnum) kinsnums active iinsnum, 0, 0 klognum = max(1,kinsnums) * -3 kampfac2 = ampdbfs(log2(max(1,kinsnums)) * -3); drop 3db every doubling. asig *= lineto(kampfac2, limit:k(ktime, 0.008, 5)) xout asig endop On Thu, Jan 7, 2021 at 7:11 AM Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
|
Date | 2021-01-07 00:02 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] Scaling amplitude depending on number of instruments |
Thanks, Thorin, I love ALL your Csound work. Inspiring..... -dB Dr. Richard Boulanger Professor of Electronic Production and Design Berklee College of Music Professional Writing and Technology Division On Wed, Jan 6, 2021 at 6:40 PM thorin kerr <thorin.kerr@gmail.com> wrote:
|