Sample
Represents an audio clip which can be edited.
Note that this is different from a sample point, which is a location within a sample's waveform at a single instance in time.
Length: int
property
The length of this sample.
For example, a 48 KHz sample that is 1 second long will have a length
of 48_000
NumChans: int
property
writable
The number of audio channels in this sample.
For example, stereo audio has 2 channels.
RegionCount: int
property
The number of regions in this sample.
Regions are specified using the yellow start and end markers in the Edison plugin's UI.
SampleRate: int
property
writable
The sample rate of this sample.
For most audio clips, this will be 44_100
for 44.1 KHz.
AmpFromTo(start, end, volume)
Amplify the waveform between the start
and end
positions
(inclusive)
Args:
-
start
(int
): the starting position -
end
(int
): the ending position -
volume
(float
): the multiplication to apply to each value
GetRegion(index)
Returns the region within this sample clip at the given index.
Args:
index
(int
): the index of the region
Returns:
Region
GetSampleAt(position, channel)
Returns the magnitude of the waveform at position on the given audio channel
Args:
-
position
(int
): position in the sample -
channel
(int
): audio channel
Returns:
float
: the magnitude at this position
LoadFromClipboard()
Load a sample from the clipboard into this sample object
This will replace any existing sample
MsToSamples(time)
Returns a position within a sample given a time in ms
Args:
time
(double
): time within the sample
Returns:
int
: position within the sample
NormalizeFormat(source, mode=7)
Normalize the format of this sample by copying properties from another sample to this one
Args:
-
source
(Sample
): the source sample to copy from -
mode
(int
, optional): the specific properties to copy. Must be some bitwise combination of:-
0b001
: number of channels -
0b010
: the sample format -
0b100
: the sample rate
Defaults to
0b001 | 0b010 | 0b100
, to copy all properties. -
NormalizeFromTo(start, end, volume, only_if_above=False)
Normalize the waveform between the start
and end
positions
(inclusive)
Args:
-
start
(int
): the starting position -
end
(int
): the ending position -
volume
(float
): ??? -
only_if_above
(bool
, optional): ???. Defaults to False
PasteFromTo(old, start, end, mode)
Copy the contents of old
into this sample.
Args:
-
old
(Sample
): The sample to copy from -
start
(int
): the starting point -
end
(int
): the ending point -
mode
(Literal[0, 1, 2]
):-
0
: Insert -
1
: Replace -
2
: Mix
-
SetSampleAt(position, channel, value)
Sets the magnitude of the waveform at position on the given audio channel
Args:
-
position
(int
): position in the sample -
channel
(int
): audio channel -
value
(float
): new magnitude
SilenceFromTo(start, end, volume)
Silence the waveform between the start
and end
positions
(inclusive).
This will set the value for each sample point to 0.0
.
Args:
-
start
(int
): the starting position -
end
(int
): the ending position
SineFromTo(start, end, frequency, phase, volume=1)
Generate a sine wave between the start
and end
positions of the
sample (inclusive).
Args:
-
start
(int
): the starting point -
end
(int
): the ending point -
frequency
(float
): the frequency of the sine wave -
phase
(float
): the phase of the sine wave -
volume
(float
, optional): the amplitude of the sine wave. Defaults to1
.
__init__()
Create an audio sample
Region
Represents a region or marker within a sample
A region is bound by a start and end point, and a marker only has a start point.
SampleEnd: int
property
The ending point of this region in samples. If this is greater than the length of the sample, then this region is actually a marker.
SampleStart: int
property
The starting point of this region in samples.