Sample
The classes and functions documented here are used to manipulate and interact with samples within the Edison editor.
EditorSample
module-attribute
The sample which is currently loaded within the Edison editor.
Editor
module-attribute
An object representing the state of the Edison editor.
For selections, if the start point is 0
and the end point is
EditorSample.Length - 1
, then the full clip is selected.
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.
MEEditor
An object representing the state of the Edison editor.
For selections, if the start point is 0
and the end point is
EditorSample.Length - 1
, then the full clip is selected.
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
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
property
writable
The number of audio channels in this sample.
For example, stereo audio has 2 channels.
SampleRate
property
writable
The sample rate of this sample.
For most audio clips, this will be 44_100
for 44.1 KHz.
RegionCount
property
The number of regions in this sample.
Regions are specified using the yellow start and end markers in the Edison plugin's UI.
GetSampleAt
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
SetSampleAt
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
NormalizeFromTo
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
AmpFromTo
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
SilenceFromTo
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
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
.
LoadFromClipboard
Load a sample from the clipboard into this sample object
This will replace any existing sample
PasteFromTo
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
-
MsToSamples
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
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. -