[Csnd] tables of sound spectra?

hi -

does anyone know internet resources about sound spectra which can be used for additive resynthesis? in particular percussive sounds.

cheers -
  joachim

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

Dear Joachim,
I assume You know the appendix “modal frequencies” of the csound manual.
Maybee I can help You with to Udos.
One Udo is for the partials of an ideal bar, following (2n+1)^2 and the other one is for stretched partials (similar to thick strings or something like this).

You will find these opcodes end of the mail.

I don’t remember where I found the formula for stretcged partials but I do remember, that values around 0.0004 are considered as being natural. Off course “insane” values sound also are very interesting.
I personally would be interested in another couple of formulas, e.g. gong, triangle, tomtom, etc.
Here my opcodes (sorry, comments are in german):

/* OPCODE FOR THE PARTIALS OF AN IDEAL BAR

SYNTAX:
StefansXylopartials inumparts,iftab
inumparts = Anzahl der Teiltoene
iftab = tabelle in die geschrieben werden soll, muss eine “leere” Tabelle sein, wie z.B.
iftab ftgen 0,0,16,-2,0 ; leere tabelle
*/
opcode StefansXylopartials, 0,ii
inumparts,iftab xin

indx = 0
inenner = 9
loop:
inZ = indx+1
izaehler = (2*inZ+1)^2
istrp = izaehler/inenner
tableiw istrp, indx, iftab ;writes istart to table
loop_lt indx, 1, inumparts+1, loop
endop

;;;;;

/*OPCODE FOR STRETCHED PARTIALS

SYNTAX:
StefansStretchedPartials inumparts,istreck,iftab
inumparts = Anzahl der Teiltoene
istreck = Streckfaktor, bis ca. 0.01 klavierähnlich, ab dann glockenspielartig
iftab = tabelle in die geschrieben werden soll, muss eine “leere” Tabelle sein, wie z.B.
iftab ftgen 0,0,16,-2,0 ; leere tabelle
*/
opcode StefansStretchedPartials, 0,iii
inumparts,istreck,iftab xin

indx = 0
inenner = sqrt(1+istreck)
loop:
inZ = indx+1
izaehler = inZsqrt(1+istreckinZ^2)
istrp = izaehler/inenner
tableiw istrp, indx, iftab ;writes istart to table
loop_lt indx, 1, inumparts, loop
endop

hi stefan -

thanks for your help. i think i was not clear enough in my question: i am searching tables of real instrument spectra, somehow reduced to what we need in additive resynthesis. yes i know this nice table: Appendix E. Modal Frequency Ratios

this can be perfectly used for modal synthesis (= the mode opcode in csound, for instance in iain's wonderful example http://iainmccurdy.org/CsoundRealtimeExamples/SoundGenerators/mode.csd). for old-fashioned additive synthesis the amplitude series are missing.

so i am looking for something like this modal table which include amplitudes for the partials.

cheers -
  joachim

Oh, yes, that would be interesting for me as well!
Stefan

I’m not sure it’s much help, but Michael Klingbeil’s SPEAR software will export freq/amp data in text format. You would need to parse it to produce anything readable but the info is there.

yeah that's an idea, thanks. also good old hetro would be a possibility, as it reduces the amount of amp/freq data via the algorithm.

I usually run through an exercise in my course where I use Audacity to
analyze a sound (using the Analyze -> Plot Spectrum menu option) to
get frequency/amplitude values and have the students use code such as:

asig = oscili(ampdbfs( *dbval1* ), *freq1*)
asig += oscili(ampdbfs( *dbval2* ), *freq2*)
asig += oscili(ampdbfs( *dbval3* ), *freq3*)

where the *values* are replaced with the numeric values from Audacity.
I also have them look at the spectrogram view in Audacity to get an
idea of evolution of amplitude over time. To simplify things I have
them analyze a guitar sample and use an expon for curves with starting
and ending values as decibels using ampdbfs.

Not sure if that's the kind of thing you're looking for but thought
it worth mentioning.

I've also found PRAAT useful for analyzing sounds, though I haven't
spent a lot of time with it.

oh yes, that is also an option. i did not look into this tool before; that is actually very useful.
thanks -
  j

I do the very same as Steven but prefer the spectrogram in Sonic Visualiser. It lets you choose very large windows sizes which give really high-res spectrograms. On the other hand, I also find it useful to open sounds in SPEAR and get the students to manually remove partials that are not so important to the overall timbre.

Finally, I have started using IZotope’s RX Elements, a slimmed down and much cheaper version of their full FX suite. It’s Mac and Windows only, but it lets you select and draw around portions of the spectrum which you can then export to a new track. Another great way of exploring a sound’s spectra.

For a more automated approach, you could look at Xavier Serra's sms-tools

It can create harmonic and inharmonic additive models with many
partials from its analysis. If you play with the settings, you can get
substantially reduced synthesis with just a few partials too.

I haven't used it for a while so I don't remember how easy it is to
get this data out but I'm sure it's possible.

Joel

Thanks Rory for mentioning Sonic Visualizer and SPEAR, I'll have to
spend more time with both. RX Elements looks quite nice too, though
I'll wait until it's on sale before exploring that one. :slight_smile: Thanks
Joel too for mentioning sms-tools!

Sorry to plug my own project, but you can take a look at GitHub - gesellkammer/loristrck: Partial tracking in python, based on Loris

Installation via

$ pip install loristrck

That will install a script loristrck_chord, which can be used as:

$ loristrck_chord -t 0.3

Sorry to plug my own side-project, but you can take a look at GitHub - gesellkammer/loristrck: Partial tracking in python, based on Loris

Installation via

$ pip install loristrck

That will install a script loristrck_chord, which can be used as:

$ loristrck_chord -t 0.3 --maxcount 6 --minamp -60 ---sound dac spring6.sdif

That will extract the chord at time 0.3 out of a previously analyzed sdif file and extract the 6 most prominent partials and output their notes, frequencies and amplitudes in csv format to stdout. It will also playback such chord or generate a soundfile.

The analysis can be done via the script "loristrck_analyze"

Hi Eduardo,

Thanks for mentioning your project, this and all of the other
libraries look great! Looking forward to trying these out.

All best,
Steven

thanks --- that might exactly offer what i am looking for.

i installed following your advice. loristrck_analyze works, but loristrck_chord is not being found. in /usr/local/bin is only
loristrck_analyze loristrck_pack loristrck_play

is it because my python is 3.7, but 3.8 is required?

best -
  joachim

very interesting what you do on top of good old loris. it is kind of overload for what i want to do, but because of your approach i thought i might use ATS partial tracking for what i wanted to achieve. the advantage is that ATSA is a built-in utility in csound, so no need to install anything else.

i have written a small csound program for it, and it works pretty well for me. i attach it, and the example files are here: GitHub - joachimheintz/cs_utils

best -
  joachim

(Attachment Ats2Add.csd is missing)

yes steven i agree.with that.

also additive partials + fm + noise source in various combinations even running noise source -> linseg/envelope -> fm pair will provide a really nice way to shape transients and that’s everything to a percussion sound. it’s mostly just transients and tone with some space.

one other thing with that method is you can use the dynamics of FM to get velocity/tone variance without filters and these kinds of things aren’t even possible in regular sine wave fm stuff, if you look at a spectrograph and divide it into sections you can take that difference and code that and because FM is linear in the same way sounds decay, it works in a weird way… also if you’re doing that kind of stuff play around with a high pass filter if you need something that isn’t muddy because the fundamental freqs tend to be the things you are fighting with that method. it’s kind of my favorite way of building instruments now

Joachim,

Worked instantly and perfectly on the Mac.

Love it!

  • hope you will add a Widget version and include it (in the Examples) with the next release of CsoundQt

  • It will be so useful in my DSP class.

  • Super appreciate that it is built into Csound

thanks! -- glad to know it is working for you and perhaps useful for someone.
cheers -
  j