rsc3/doc-schelp/Help-3.12.2/Classes/Chromagram.html

165 lines
6.9 KiB
HTML
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
<html><head><title>Chromagram</title>
<link rel='stylesheet' href='./../scdoc.css' type='text/css' />
<link rel='stylesheet' href='./../frontend.css' type='text/css' />
<link rel='stylesheet' href='./../custom.css' type='text/css' />
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<script src='./../scdoc.js' type='text/javascript'></script>
<script src='./../docmap.js' type='text/javascript'></script>
<script src='./../prettify.js' type='text/javascript'></script>
<script src='./../lang-sc.js' type='text/javascript'></script>
<script type='text/javascript'>var helpRoot='./..';</script>
</head>
<ul id='menubar'></ul>
<body onload='fixTOC();prettyPrint()'>
<div class='contents'>
<div class='header'>
<div id='label'>SuperCollider CLASSES (extension)</div>
<div id='categories'><a href='./../Browse.html#UGens>Analysis'>UGens>Analysis</a></div>
<h1>Chromagram</h1>
<div id='summary'>Octave chroma band based representation of energy in a signal; Chromagram for nTET tuning systems with any base reference</div>
</div>
<div class='subheader'>
<div id='filename'>Source: <a href='file:///Users/zzk/Library/Application Support/SuperCollider/Extensions/SCMIRUGens/Classes/Chromagram.sc'>/Users/zzk/Library/Application Support/SuperCollider/Extensions/SCMIRUGens/Classes/Chromagram.sc</a></div><div id='superclasses'>Inherits from: <a href="../Classes/MultiOutUGen.html">MultiOutUGen</a> : <a href="../Classes/UGen.html">UGen</a> : <a href="../Classes/AbstractFunction.html">AbstractFunction</a> : <a href="../Classes/Object.html">Object</a></div>
<div id='related'>See also: <a href="./../Classes/SensoryDissonance.html">SensoryDissonance</a></div>
</div>
<div id='toc'>
<ul class='toc'><li class='toc1'><a href='#description'>Description</a></li>
<ul class='toc'></ul><li class='toc1'><a href='#classmethods'>Class methods</a></li>
<ul class='toc'><li class='toc3'><a href='#*kr'>kr</a> </li>
<li class='toc2'><a href='#Inherited%20class%20methods'>Inherited class methods</a></li>
</ul><li class='toc1'><a href='#instancemethods'>Instance methods</a></li>
<ul class='toc'><li class='toc2'><a href='#Inherited%20instance%20methods'>Inherited instance methods</a></li>
</ul><li class='toc1'><a href='#examples'>Examples</a></li>
<ul class='toc'></ul></ul></div><a class='anchor' name='kw_Chroma'>&nbsp;</a><a class='anchor' name='kw_pitch%20class'>&nbsp;</a><a class='anchor' name='kw_equal%20temperament'>&nbsp;</a><a class='anchor' name='kw_filter%20bank'>&nbsp;</a><h2><a class='anchor' name='description'>Description</a></h2>
<p>A chromagram, measuring the energy at particular chroma within an nTET tuning system.
<p>Possible extension: TODO: Could have arbitrary tuning systems if precalculated the exact fft bin + interpolation data.<h2><a class='anchor' name='classmethods'>Class Methods</a></h2>
<h3 class='cmethodname'><span class='methprefix'>*</span><a name='*kr' href='./../Overviews/Methods.html#kr'>kr</a> (<span class='argstr'>fft</span>, <span class='argstr'>fftsize: 2048</span>, <span class='argstr'>n: 12</span>, <span class='argstr'>tuningbase: 32.703195662575</span>, <span class='argstr'>octaves: 8</span>, <span class='argstr'>integrationflag: 0</span>, <span class='argstr'>coeff: 0.9</span>, <span class='argstr'>octaveratio: 2</span>, <span class='argstr'>perframenormalize: 0</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>fft<td class='argumentdesc'>
<p>input fft chain, that is, from an FFT UGen<tr><td class='argumentname'>fftsize<td class='argumentdesc'>
<p>FFT size, required for initialisation<tr><td class='argumentname'>n<td class='argumentdesc'>
<p>Equal divisions of an octave, e.g. n=12 is 12TET, 12 steps in an octave<tr><td class='argumentname'>tuningbase<td class='argumentdesc'>
<p>Base frequency or tuning; will correspong to index 0 in results (conventionally, this would be a 'C' in 12TET, but its an arbitrary reference)<tr><td class='argumentname'>octaves<td class='argumentdesc'>
<p>Number of octaves considered from tuning base up<tr><td class='argumentname'>integrationflag<td class='argumentdesc'>
<p>Whether to integrate from frame to frame, off by default<tr><td class='argumentname'>coeff<td class='argumentdesc'>
<p>Coefficient of integration<tr><td class='argumentname'>octaveratio<td class='argumentdesc'>
<p>Default of 2 is a 'normal' octave; other ratios are possible, e.g. Bohlen-Pierce scale uses 13 equal divisions over the ratio of 3 for a 'tritave'<tr><td class='argumentname'>perframenormalize<td class='argumentdesc'>
<p>Defaults to off, but if set to 1 will normalize each frame with respect to itself (as long as there is non-negligible power), potentially providing a more robust measure for comparison between frames (each frame will have then a normalized distribution over chroma, independent of volume)</table></div><h3><a class='anchor' name='Inherited%20class%20methods'>Inherited class methods</a></h3>
<div id='inheritedclassmets'></div><h2><a class='anchor' name='instancemethods'>Instance Methods</a></h2>
<h3><a class='anchor' name='Inherited%20instance%20methods'>Inherited instance methods</a></h3>
<div id='inheritedinstmets'></div><h2><a class='anchor' name='examples'>Examples</a></h2>
<pre class='code prettyprint lang-sc'>(
{
var in, fft, chroma;
//in = SinOsc.ar(440,0,0.1);
in= SoundIn.ar;
fft = FFT(LocalBuf(2048), in);
chroma=Chromagram.kr(fft);
chroma.poll;
Out.ar(0,Pan2.ar(in));
}.play
)
//n TET display
n= 12; //19, 24
(
x = {
var in, fft, chroma;
//in = SinOsc.ar(440,0,0.1);
in= SoundIn.ar;
fft = FFT(LocalBuf(2048), in);
chroma=Chromagram.kr(fft, 2048, n);
//chroma=Chromagram.kr(fft, 2048, n, 36.midicps, 7, 1, 0.9);
Out.kr(0,chroma);
}.play;
c= Bus.new('control', 0, n);
)
//poll coefficients snapshot
c.getn(n,{arg val; {val.plot;}.defer});
//Continuous graphical display of Chromagram values; free routine before closing window
(
var ms;
w=Window.new((n.asString)++" chroma coefficients", Rect(200,400,n*20+50,300));
ms= MultiSliderView.new(w, Rect(10,10,n*20,280));
ms.value_(Array.fill(n,0.0));
ms.valueThumbSize_(20.0);
ms.indexThumbSize_(20.0);
ms.gap_(0);
w.front;
r= {
inf.do{
c.getn(n,{arg val; {ms.value_(val)}.defer});
0.04.wait; //25 frames per second
};
}.fork;
w.onClose = {
r.stop;
c.free;
x.free;
};
)
b.free;
//Bohlen-Pierce over 3 tritaves, normalized results per frame
(
{
var in, fft, chroma;
//in = SinOsc.ar(440,0,0.1);
in= SoundIn.ar;
fft = FFT(LocalBuf(2048), in);
chroma=Chromagram.kr(fft,2048,13,octaves:3,octaveratio:3,perframenormalize:1);
chroma.poll;
Out.ar(0,Pan2.ar(in));
}.play
)</pre>
<p><div class='doclink'>helpfile source: <a href='file:///Users/zzk/Library/Application Support/SuperCollider/Extensions/SCMIRUGens/HelpSource/Classes/Chromagram.schelp'>/Users/zzk/Library/Application Support/SuperCollider/Extensions/SCMIRUGens/HelpSource/Classes/Chromagram.schelp</a><br>link::Classes/Chromagram::<br>sc version: 3.8.0</div></div></body></html>