support sample stretching

This commit is contained in:
2023-09-24 23:35:37 +02:00
parent 2843b65122
commit 759c60dbf9
2 changed files with 79 additions and 62 deletions

View File

@ -295,6 +295,13 @@ export class SoundEvent extends AudibleEvent {
public size = (value: number) => this.updateValue("size", value); public size = (value: number) => this.updateValue("size", value);
public sz = this.size; public sz = this.size;
// Unit
public stretch = (beat: number) => {
this.updateValue("unit", "c");
this.updateValue("speed", 2 / beat)
return this;
}
// ================================================================================ // ================================================================================
// AbstactEvent overrides // AbstactEvent overrides
// ================================================================================ // ================================================================================

View File

@ -188,6 +188,7 @@ There are some basic controls over the playback of each sample. This allows you
| loopBegin | | Beginning of the loop section (between <ic>0</ic> and <ic>1</ic>) | | loopBegin | | Beginning of the loop section (between <ic>0</ic> and <ic>1</ic>) |
| loopEnd | | End of the loop section (between <ic>0</ic> and <ic>1</ic>) | | loopEnd | | End of the loop section (between <ic>0</ic> and <ic>1</ic>) |
| loop | | Whether to loop or not the audio sample | | loop | | Whether to loop or not the audio sample |
| stretch | | Stretches the audio playback rate of a sample over <ic>n</ic> beats |
| speed | | Playback speed (<ic>2</ic> = twice as fast) | | speed | | Playback speed (<ic>2</ic> = twice as fast) |
| cut | | Set with <ic>0</ic> or <ic>1</ic>. Will cut the sample as soon as another sample is played on the same bus | | cut | | Set with <ic>0</ic> or <ic>1</ic>. Will cut the sample as soon as another sample is played on the same bus |
| clip | | Multiply the duration of the sample with the given number | | clip | | Multiply the duration of the sample with the given number |
@ -207,6 +208,15 @@ beat(.5)::snd('pad').begin(0.2)
true true
)}; )};
${makeExample(
"Playing an amen break",
`
// Note that stretch has the same value as beat
beat(4) :: sound('breaks165').stretch(4).out()
beat(0.25) :: sound('hh').out()
beat(1, 4, 8) :: sound('bd').out()`,
true,
)};
## Filters ## Filters