Skip to content

Sample

The classes and functions documented here are used to manipulate and interact with samples within the Edison editor.

EditorSample module-attribute

EditorSample = Sample()

The sample which is currently loaded within the Edison editor.

Editor module-attribute

Editor = 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.

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.

SampleStart property

SampleStart: int

The starting point of this region in samples.

SampleEnd property

SampleEnd: int

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.

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.

SelectionStartS property

SelectionStartS: int

The starting point of the selection within the editor.

SelectionEndS property

SelectionEndS: int

The ending point of the selection within the editor.

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

Length: int

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

NumChans: int

The number of audio channels in this sample.

For example, stereo audio has 2 channels.

SampleRate property writable

SampleRate: int

The sample rate of this sample.

For most audio clips, this will be 44_100 for 44.1 KHz.

RegionCount property

RegionCount: int

The number of regions in this sample.

Regions are specified using the yellow start and end markers in the Edison plugin's UI.

__init__

__init__() -> None

Create an audio sample

GetSampleAt

GetSampleAt(position: int, channel: int) -> float

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

SetSampleAt(position: int, channel: int, value: float) -> None

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

NormalizeFromTo(start: int, end: int, volume: float, only_if_above: bool = False) -> None

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

AmpFromTo(start: int, end: int, volume: float) -> None

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

SilenceFromTo(start: int, end: int, volume: float) -> None

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

SineFromTo(start: int, end: int, frequency: float, phase: float, volume: float = 1) -> None

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 to 1.

LoadFromClipboard

LoadFromClipboard() -> None

Load a sample from the clipboard into this sample object

This will replace any existing sample

PasteFromTo

PasteFromTo(old: Sample, start: int, end: int, mode: Literal[0, 1, 2]) -> None

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

MsToSamples(time: float) -> int

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

NormalizeFormat(source: Sample, mode: int = 7) -> None

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.

GetRegion

GetRegion(index: int) -> Region

Returns the region within this sample clip at the given index.

Args:
  • index (int): the index of the region
Returns:
  • Region