Skip to content

Commit 55f87eb

Browse files
author
vlazzarini
committed
added some more material to what's new
1 parent 251bd41 commit 55f87eb

File tree

1 file changed

+85
-4
lines changed

1 file changed

+85
-4
lines changed

docs/intro/whats-new-in-csound-7.md

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# What's new in Csound 7
1+
-# What's new in Csound 7
22

33
Csound 7 brings major changes which offer new possibilities for users and modernize coding. Nevertheless Csound 7 keeps backwards compatibility: Despite new syntax features any valid Csound code from the past can be run without any code change.
44

@@ -18,6 +18,9 @@ endin
1818
schedule(1,0,2)
1919
```
2020

21+
In addition, a number of new variable types have been introduced.
22+
23+
2124
## New UDO Syntax and Pass-by-reference
2225

2326
User Defined Opcodes now follow the syntax `opcode name(inargs):(outargs)`.
@@ -38,9 +41,24 @@ endin
3841
schedule(1, 0, 0)
3942
```
4043

41-
<span style="color:red">Give example for pass-by-reference ...</span>
44+
When the new opcode syntax is used, the default call semantics is by
45+
reference, instead of copy. The exceptions are when local sampling
46+
rate or local ksmps are used, when pass-by-copy is used. In
47+
pass-by-reference semantics all arguments data are shared between the
48+
caller and the UDO.
49+
50+
The classic opcode syntax always implies pass-by-copy.
51+
52+
## Local Sampling Rate for UDOs
4253

43-
## Removed Limitations for Functional Style
54+
UDOs can now be set to a local sampling rate, which may be higher
55+
or lower than the calling environment. The opcodes `oversample` and
56+
`undersample` are used to set the local sampling rate. The limitations
57+
are that the sampling rate always needs to be an integer multiple or
58+
divisor of the caller sampling rate and local ksmps are not allowed
59+
together with local sampling rates.
60+
61+
## Functional Style Enhancements
4462

4563
Multiple output arguments can now be used in functional style, e.g.
4664

@@ -54,12 +72,21 @@ endin
5472
schedule(1, 0, 1)
5573
```
5674

57-
## For-Loop
75+
Additionally, the new parser makes functional expressions behave
76+
exactly as the classic syntax, with no penalties.
5877

78+
<!--
79+
For-Loop
5980
<span style="color:red">Is it going to happen??</span>
81+
-->
6082

6183
## User-Defined Types
6284

85+
The type system in Csound 7 is very sophisticated and it allows new
86+
types to be added using Csound code (similarly to user-defined
87+
opcodes). Once created, these types are available to define new
88+
variables, arguments etc.
89+
6390
```csound-orc
6491
struct MyType val0:i, val1:i
6592
@@ -70,3 +97,57 @@ print(testVal.val1)
7097
endin
7198
schedule(1, 0, 0)
7299
```
100+
101+
## Instrument Definition Type
102+
103+
Csound 7 introduces a new type `InstrDef` to hold instrument
104+
definitions. The _name_ of an instrument becomes a global constant of
105+
that type, which may be referred directly in the code,
106+
107+
```
108+
instr Ping
109+
out(oscili(expon(p4,p3,0.001), p5))
110+
schedule(Ping,0.1,0.2,rnd(0.5),500+rnd(100))
111+
endin
112+
schedule(Ping,0,0.2,0.5,500)
113+
```
114+
115+
Furthermore, instrument definitions can be created directly from
116+
Csound code. If the `InstrDef` var is not yet available, we
117+
can use the self-reference `this_instr`. The following
118+
code demonstrates this,
119+
120+
```
121+
Ping:InstrDef = create({{
122+
out(oscili(expon(p4,p3,0.001),p5))
123+
schedule(this_instr,0.1,0.2,rnd(0.5),500+rnd(100))
124+
}})
125+
schedule(Ping,0,0.2,0.5,500)
126+
```
127+
128+
Notice that with this code pattern, we do not need to enclose the
129+
instrument inside `instr` and `endin`, and the instrument
130+
number is assigned dynamically.
131+
132+
## Instrument Instance Type
133+
134+
Instrument instances can be assigned to variables and manipulated
135+
by opcodes.
136+
137+
138+
## Opcode Reference and Opcode Types
139+
140+
References to opcodes can be assigned to variables and instantiated
141+
as Opcode-type objects.
142+
143+
## Complex Type
144+
145+
Complex numbers are supported natively in the language now.
146+
147+
## Limitations Removed
148+
149+
The previous power-of-two limitation for table sizes has been removed,
150+
so that any size tables can be used everywhere.
151+
152+
The limitation of event parameter numbers has been lifted, any number
153+
of parameters are possible everywhere.

0 commit comments

Comments
 (0)