いらないモノ、ひつようなモノ

書籍、音楽、そして若干のテクノロジー

csound6なにが新しいの?

まえおき

 
最近MLもチェックしていなかったし、
にしっかりバージョンアップのお知らせが、
7月16日付けで掲載されている。
csound5はcsound5.19を最後に、
メジャーバージョンのアップであるけど、
一応csd/orc/scoファイル上の
バックワードコンパチビリティは
保った上でのバージョンアップらしい。
ただ、APIはずいぶん変わってこれは
コンパチじゃないらしい、が、
このAPI使っている人ってほとんど、
居ないんじゃないかぁ。っていうか、
ほとんどマニアックなのに、
続いているところが極めてすごい。
 
 
csound6の変更点をかいつまんで
 
o A --sample-accurate option provides sample-accurate timing
of score events. This breaks backward compatibility for plugin opcodes,
which require code changes for tracking current sample frame
position in audio type variables (see below for an example).
 
まず、--sample-accurateというコマンドラインオプションが増えたらしい。
が、マニュアルに書いていない気がする。csoundはサンプリングレート
とは別のk-rateという概念があって、この単位で信号処理の計算をする。
計算の粒度みたいなもの、k-rateを下げれば大雑把な単位で計算するから
当然発音タイミングもずれるけど、このオプションでそれだけは
正確に保たれるというもの「なんだろう」。試してないからわからないが。
オプションの量から見ても始めて取り掛かる人にはやさしくないよな。
 
o A --realtime option, which can also be enabled by setting the
CSOUND_PARAMS field realtime_mode to 1, provides asynchronous execution
of file reading and writing, and of init-time orchestra code.
This should make real-time operation of Csound more resistant to dropouts.
 
今回はマルチコアを意識したコードに基本的に書き換えていて、
タスクのディスパッチングを大きく見直したらしい。
オーディオのread/writeなど別スレッドにするなど。
ま、このパラメータを入れると、たくさんリソース使って、
リアルタイム処理をよりがんばってくれるということなのかも。
 
o New opcodes and syntax support arrays of arbitrary dimensionality.
Arrays are created (usually) with the init opcode or with fillarray:
k1 init 4
generates a k-rate 1-dimensional array of length 4. Similarly,
a2 init 4, 4
creates a square, 4 x 4 a-rate array. Or,
k2 fillarray 1, 2, 3, 4
creates a 4-element vector filled with {1, 2, 3, 4}, and implicitly
defines a length. Array elements are indexed with brackets [] such as k1[2] or
a2[2][3]. One dimensional arrays replace tvars, and can be used in opcodes like
maxtab/maxarray, mintab/minarray and sumtab/sumarray (see below).
Array setting can also be done on the left-hand side of opcodes, e.g.:
aSigs[0] vco2 .1, 440
aSigs[1] vco2 .1, 880
 
配列が今になってサポートされる言語はcsoundだけじゃないだろうか。
ほかの言語の何十年昔を行っているのだろうか。すごい。すごすぎる。
いや、でもcsound大好きなんだけどね。
 
o Multicore support has been completely rewritten using an improved
algorithm for task dispatching, which should use less memory and fewer locks.
Multicore benchmarks are now much faster than before. Multithreading often
provides significant speedups over single-threaded rendering.
 
シングルスレッドで音をレンダリングするよりずっと早くなったって、
やはりこれも最先端の世界からはどれだけ遅れをとっているのか。
誰か金持ちがお金出してあげて、最新化すれば済むけど、儲からないから
そんなことする人は居ないか。
 
 
o Compilation of instruments and orchestra code can be done at any stage;
new instruments can be added or can replace old instruments with the
same name/number even while Csound is running.
 
csoundの動作中にダイナミックに楽器ファイルを
入れ替えるkとができるようになったそうです。
より、パフォーマンスを意識したつくりになりつつあります。
 
 
o The Csound API has been cleaned up and extended to support new functionality.
 
CsoundAPIが変わったてことね。
 
 
=================
USER-LEVEL CHANGES
=================
 
 
New opcodes:
o faustgen
 
そもそもそも。faustって?なに?
メインのサイトは、http://faust.grame.fr/
Functional AUdio STreamの略語の新しい(?)信号処理をベースとする
音響処理言語のようです。MAX/MSPにもfaustgen~があるみたい。
 
 
<CsInstruments>
 
nchnls=2
0dbfs = 1
 
giPluck faustcompile {{
import("music.lib");
 
// Excitator
//--------
 
upfront(x) = (x-x') > 0.0;
decay(n,x) = x - (x>0.0)/n;
release(n) = + ~ decay(n);
trigger(n) = upfront : release(n) : >(0.0);
 
size = hslider("excitation", 128, 2, 512, 1);
// resonator
//-----------------
 
dur = hslider("duration", 128, 2, 512, 1);
att = hslider("attenuation", 0.1, 0, 1, 0.01);
average(x) = (x+x')/2;
 
resonator(d, a) = (+ : delay(4096, d-1.5)) ~ (average : *(1.0-a)) ;
 
process = noise * hslider("level", 0.5, 0, 1, 0.01)
: vgroup("excitator", *(button("play"): trigger(size)))
: vgroup("resonator", resonator(dur, att));
}}, "-vec -lv 1"
 
instr 1
i3, a1 faustaudio giPluck
k1 line p5, p3, p5*1.2
faustctl i3,"duration", sr/k1
faustctl i3,"attenuation", 0.01
faustctl i3,"play", 1
event_i "i",1, 0.1, 1, 1, 200+rnd(200)
outs a1,a1
endin
 
</CsInstruments>
 
こうのfaustコードは、ホームページのonline exampleから
探すことができるようです。karplus32で、同じものが出ていた。
 
 
o array -- many new or revised opcodes -- see below under orchestra.
 
ま、これは配列関連のopcodeでしょう。
 
 
o compileorc -- takes a filename containing a collection if instrument
definitions and compiles them, replacing existing versions.
It returns 0 on success.
 
どういう場面で使うのか良くわかんないですが、ORCファイルを
コンパイルして付け加えるみたいです。なんか、動的に楽器を作るときに
これを使うのでしょうか。事前に定義された楽器なら最初から
読み込めばいいはずですからねぇ。。
 
 
o compilestr -- like compileorc, but takes a string of orchestra code.
引数が文字列そのものを持ってきて楽器を付け足すみたいです。これは、
もっと使い方がわかんない。。。
 
 
o readscore -- runs the score preprocessor on a string and then schedules
new events via the RT event mechanism, returning 0 if successful.
スコアのプリプロセッサにかけてからスコアに動的に付け加える。
プリプロセッサがあるから現在の状態に、、みたいなことができるのが、
ポイントかもしれません。
 
 
o Instruments can run at local values of ksmps using
setksmps iksmps
as in Csound 5 UDOs.
 
まぎれて重要っぽいことが。
 
o Compilation can be done at any stage; new instruments can be
added or can replace old instruments with the same name/number.
同じ名前を使って、楽器を置き換えられる。これは、compileorcなどで
述べたことと同じ。
 
Running instances of old instrument definitions are not affected.
The only limitation is that header constants in instr 0 are read only
once at the time of the first compilation.
 
instr 0だけは特別で置き換えができないってことですね。
 
Init-time code can be placed outside instruments
in the global space, but this also will be
executed only once following the compilation.
 
initなどの初期設定コードなどは一回しか実行されないよ、
ということですね。
 
In this way, score event
generation can be completely replaced by orchestra code.
See also the new opcodes compileorc and compilestr.
だから、スコアもぜんぜん変えちゃうことができるのよねー
ということ、ま、そうなんでしょう。
 
 
o New syntax operators +=, -=, *= and /=. These are more than
syntactic sugar; please use += and -= for accumulating reverbs
as it gives better multicore behaviour.
 
お、これは気になる。やはり随分昔に
議論されていたことではあるが、+=などが導入。
で、重要なこととして、Syntactic sugreじゃないの、
舐めないでということが、あ、 糖衣構文という、きちんとした
意味があったのか(汗)だから、
 
リバーブの音の積み重ねについては、マルチコアなら、
いい感じになります。ということだそうです。
 
 
o The opcodes add, sub, mul and div have been deleted; use the
forms + - * /. Not many people were aware of these opcodes.
 
addとか、記号じゃないopcodeはdepricatedということ。
普通に足し算引き算の記号使え、ということ。
 
o Any opcode with zero outputs or one output can be used
as a function. Some opcodes might require type annotation to
resolve ambiguities; see the the new syntax page in
the Csound 6.00 manual.
 
んー、意味わかんないかも。csoundでいうところの、
関数がなんだかよくわからん。
 
o A statement can be broken across lines after a , = or
any arithmetic operation.
 
算術計算している途中で文章が行替えしてもいいということかな?
 
o There are a range of new or recoded operations on k-valued
arrays, most restricted to 1 dimensional arrays (vectors):
kans minarray ktab returns the smallest value in the
(possibly) multidimensional array
kans maxarray ktab returns its largest value
kabs sumarray ktab returns sum of all values in the array
ktab genarray imin, imax[, inc]
generates vector of values from imin
to imax by increments of inc (default 1)
ktab2 maparray ktab1, "sin" maps the k-rate 1-arg function in
the string to every element of the vector
ktab2 maparray_i ktab1, "sin" maps the i-rate 1-arg function
in the string to every element of the vector
ktab2 slicearray ktab1, istart, iend
returns a slice of ktab1 from ktab1[istart]
to ktab1[iend]
copyf2array ktab, kfn copies data from an ftable to a vector
copya2ftab ktab, kfn copies data from a vector to an ftable.
 
だからなんなんだ、疲れてきた。個別によみゃ、いいじゃん。
 
o Arithmetic on arrays is allowed. In particular addition,
subtraction, multiplication, and division are provided in arithmetic
syntax on vectors. Similar operations between arrays and scalars are
also allowed.
 
配列間の計算、配列とスカラ値の計算ができるよ。。そりゃそうだろね。
配列導入したんだから。
 
o Each instance of every instrument has a scratchpad of 4 values
that persists after turnoff; this allows values to carry to next use of the
instrument; this may be useful for legato etc.
 
本気でわからない。scratchpadが
 
o If a table number is given as -1 then an internal sine wave
equivalent to "f. 0 16384 10 1" is used. Attempts to write to
this table will give unpredictable results, but is not
policed. The 16384 can be change by command line option
--sine-size=# where the # is rounded up to a power of two.
 
テーブル番号-1はサインにしたんだって。
大きさは2のべき乗でコマンドライン指定できるんだってー
(なげやり)
 
o A number of oscil opcodes now have the f-table parameter as
optional, defaulting to the internal sine wave. (oscil1,
oscil1i, oscil, oscil3, oscili, foscil, foscil1, loscil,
loscil3, poscil, poscil3)
 
oscilオプコード群はf-tableをオプションのパラメータにして、
デフォルト値はSINなんだってーーー
 
 
Score:
 
o Score lines can have multiple strings.
 
重要そうだけど意味がわからん。複数の文字列を持つことができるって???
あ、
 
i 1 0 10 "A4"
みたいにいままでは、文字列が一つしかかけなかったのが、いくつでもということか。
マニュアルはまだひとつだけって書いてる。
 
 
o Change to escape characters in score strings -- they do not happen.
they do no happen ??って??
 
 
 
Modified Opcodes and Gens:
o The k() function can take an a-rate argument, in which case it
invokes a call to the downsamp opcode.
Utilities:
 
o Hetro/adsyn analysis files can be machine byte-order
independent if created with -X. The down side is a longer file
and a little slower loading. The het_export utility will
create the independent format from the old, and het_import is
no longer necessary.
o cvanal and lpanal will produce machine independent files if the -X
option is used. The convolve and lpread etc. opcodes will
accept either format. You are encouraged to use the machine
independent form. Analysis files produced with -X can be used
on other systems.
 
Frontends:
o CsoundQt has been ported to Csound 6.
o CsoundVST has been ported to Csound 6.
o A new Csound6 app for Android has been developed, extending the
Csound 5 app with:
(1) An improved user interface, including text editing, scrolling
performance messages, a built-in User Guide, and links to the
Csound manual and Web site.
(2) Plugin opcodes, including the signal flow graph opcodes, the
FluidSynth opcodes, and the Lua opcodes, which enable executing
arbitrary Lua coded in Csound using the very fast LuaJIT engine,
even writing opcodes in Lua, and calling any public C function from
Csound using LuaJIT's FFI.
 
なんで、LUAなんてマイナーな言語使っているんでしょうか。
それともそんなにマイナーじゃないのか。よくわからん。
 
 
General usage:
o The environment variables for module directories have been renamed
OPCODE6DIR64 or OPCODE6DIR (note the 6) so they can co-exist with
directories for Csound 5 modules.
 
csoud6からopcodeの環境変数が変わりました!
 
 
o Similarly, .csoundrc has been renamed .csound6rc.
 
同じく初期化ファイルも名前が変わりました!
Csound's string variable type has been re-implemented.
The OENTRY structure has been changed. It has a new dependency field.
This field is now required for multicore semantics. Setting this field to -1
safely disables parallel execution, but it is recommended to enable parallel
execution by using the flags defined in include/interlocks.h
If your opcode reads or writes to zak space, use ZR or ZW, or ZB for both.
Similarly, if it reads or writes tables, use TR, TW or TB. If it reads or
writes to channels, use CR, CW and CB. If it uses the stack, use SK.
If it outputs text, then use WR to stop mixing of output. The _QQ flag marks
an opcode as deprecated. Other flags may be added later.
All opcodes that touch audio should take note of sample-accurate code.
A number of previous API functions have been removed. OpenFile and OpenFile2
have both been replaced by new OpenFile2 with an additional argument.
Additions have been made for arg type specifications for opcodes.
o Any-types have been added, as follows:
* '.' signifies a required arg of any-type
* '?' signifies an optional arg of any-type
* '*' signifies a var-arg list of any-type
o Arrays are now specified using "[x]" where x is a type-specifier.
The type-specifier can be any of the of the current specifiers,
including any-types. See Opcodes/arrays.c for examples of usage.
 
===================================
NEW TYPE SYSTEM
===================================
A new type system has been added to Csound6, and significant changes
have been made to the compiler. The previous system for handling types
involved reading the first letter of a variable's name every time
the variable was used to determine its type. This meant there was much
re-checking of types. Also, adding new types was difficult, because much
custom code had to be updated to check for new type letters.
 
いままで、Csoundにおいて変数の型定義は、最初の文字で行ってました。
#そうそう、すごいシステム!
 
In Csound6, a separate system of types has been added. Types are defined as
CS_TYPEs. The creation of variables from types and the initialisation
of memory has been encapsulated within the CS_TYPEs. This change
allows easier addition of new types, as well as generic calculations of
memory pools, amongst other things.
 
CS_TYPEsdで新たに型を定義するようにしたって?
また独自路線を行くのですね。。ついていきます。。。。。(泣)
 
The compiler has been changed to use the new type system in its semantic
checking phase. Variables are now registered into a CS_VAR_POOL when they
are first defined, with the CS_VARIABLE having a reference to its CS_TYPE.
After first time definition within the pool, the type information is looked
up in consequent variable uses, rather than re-calculated from the variable
name. This opens up possibilities for new variable naming and typing
strategies, i.e. using "myVar:K" to denote a k-rate arg. It also
opens up possibilities for user-defined types, such as
"data myType kval, aval", then using "myVar:myType" to define a var
of that type. (The previous is speculative, and is not an active
proposal at this time.)
 
 
The addition of the type system has formalised the static type system
that has existed in Csound prior to Csound6. It has, arguably, simplified
the code-base in terms of type handling, as well as laid groundwork
for future type-related research to be integrated into Csound.
 
 
よよよよよー、どこまでもついてゆくぞよ。