[obsidian] vault backup: 2025-08-27 20:24:59[
Some checks are pending
Build / build (push) Has started running
Some checks are pending
Build / build (push) Has started running
This commit is contained in:
@@ -103,45 +103,70 @@ fn region_transformer(origin:Region,fx:FX) -> 'Region{
|
||||
|
||||
```rust
|
||||
fn apply_fadeinout(s,start,tin,dur,tout){
|
||||
let end = start+dur
|
||||
if now < start | now > end | tin<=0 | tout <= 0{
|
||||
0
|
||||
}else{
|
||||
let gain_s = min(max(now - start,0)/tin ,1)
|
||||
let gain_e = min(max(end - now,0)/tout,1)
|
||||
s*gain_s*gain_e // gain_sとgain_eはどちらから0~1の区間もう片方が1
|
||||
}
|
||||
let end = start+dur
|
||||
if now < start | now > end | tin<=0 | tout <= 0{
|
||||
0
|
||||
}else{
|
||||
let gain_s = min(max(now - start,0)/tin ,1)
|
||||
let gain_e = min(max(end - now,0)/tout,1)
|
||||
s*gain_s*gain_e // gain_sとgain_eはどちらから0~1の区間もう片方が1
|
||||
}
|
||||
}
|
||||
fn finout_generator(s,start,dur){
|
||||
//パラメーターはステージ1では単なる変数参照になる
|
||||
let time_in = Param!(0.0,"fade_in",0..=f64::MAX);
|
||||
let time_out = Param!(0.0,"fade_out",0..=f64::MAX);
|
||||
apply_fadeinout(s,start,time_in,dur, time_out)
|
||||
}
|
||||
fn fade_inout(origin:Region)-> 'Region{
|
||||
let new_generator = |s,start,dur| {
|
||||
//パラメーターはステージ1では単なる変数参照になる
|
||||
let time_in = Param!(0.0,"fade_in",0..=f64::MAX);
|
||||
let time_out = Param!(0.0,"fade_out",0..=f64::MAX);
|
||||
apply_fadeinout(s,start,time_in,dur, time_out)
|
||||
};
|
||||
region_transformer(origin,new_generator)
|
||||
region_transformer(origin,finout_generator)
|
||||
}
|
||||
...
|
||||
fade_inout!(some_region)
|
||||
```
|
||||
|
||||
### リージョンに対するリバース
|
||||
|
||||
```rust
|
||||
fn reverse(origin:Region)->Region{
|
||||
//クロージャとして値を閉じ込める
|
||||
let new_cache = origin |> render
|
||||
|
||||
Region{
|
||||
start:origin.start,
|
||||
dur:origin.dur,
|
||||
content: | | {
|
||||
let index = origin.dur - origin.start - now
|
||||
new_cache[index]
|
||||
}
|
||||
//クロージャとして値new_cacheを閉じ込める
|
||||
let new_generator = |s,start,dur| {//実際にはsは使わない
|
||||
//s is not used
|
||||
let index = dur - start - now
|
||||
new_cache[index]
|
||||
}
|
||||
region_transformer(origin,new_generator)
|
||||
}
|
||||
...
|
||||
some_region |> reverse!(_) |> fade_inout!(_)
|
||||
```
|
||||
|
||||
## トラックの中で別のトラックの信号を参照する
|
||||
|
||||
```rust
|
||||
fn phasor(freq){
|
||||
self+freq/samplerate % 1.0
|
||||
}
|
||||
fn sinosc(freq,amp){
|
||||
phase*TWOPI |> sin
|
||||
}
|
||||
// --ここから上はstage 1 value
|
||||
|
||||
//track_1はstage0として参照する
|
||||
let track1 = Track(|| phasor(1.0)|> scale(_,0.0,1.0,100,4000))
|
||||
|
||||
//track1をfrequencyとして参照することにする
|
||||
|
||||
let r1 = {
|
||||
start: 100ms,
|
||||
dur: 1000ms,
|
||||
content: || sinosc(track1(), 1.0)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### 他
|
||||
|
||||
- ドラッグしてるオブジェクトのスナップ対象は例えばCubaseなら固定のグリッドor既存のイベントorその両方とかだけど、例えばグリッドをジェネラティブに生成できる
|
||||
|
Reference in New Issue
Block a user