Extract - Maple Help

AudioTools

 Extract
 extract a piece of an audio recording

 Calling Sequence Extract(audArray, timeRange)

Parameters

 audArray - the Array, Vector, or Matrix containing the audio data timeRange - the time period to extract

Description

 • The Extract command extracts a piece of an audio recording and returns a new audio object containing the extracted piece.
 • The audArray parameter must be a dense, rectangular, one or two dimensional Array, Vector, or Matrix with datatype=float[8].
 • The timeRange parameter can be either a number, or a range of numbers. In either case, positive values refer to times relative to the beginning of audArray, whereas negative values refer to times relative to the end of audArray.
 If a number is specified, Extract extracts that many seconds from the beginning (if positive) or end (if negative) of audArray.
 If a range is specified, the data between those two points in time is extracted. Negative values are treated as described above.
 • Because Extract can only work to the nearest whole sample, the precise duration of the result may be slightly more or less than what was specified by timeRange.

Examples

 > $\mathrm{audiofile}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/audio/stereo.wav"\right):$
 > $\mathrm{with}\left(\mathrm{AudioTools}\right):$
 > $\mathrm{aud}≔\mathrm{Read}\left(\mathrm{audiofile}\right)$
 ${\mathrm{aud}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {19962}\\ {"Duration"}& {0.90531}{}{s}\end{array}\right]$ (1)
 > $\mathrm{dur}≔\mathrm{evalf}\left(\mathrm{Duration}\left(\mathrm{aud}\right)\right)$
 ${\mathrm{dur}}{≔}{0.9053061224}$ (2)
 > $\mathrm{middle}≔\mathrm{Extract}\left(\mathrm{aud},0.1..-0.1\right)$
 ${\mathrm{middle}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {15553}\\ {"Duration"}& {0.70535}{}{s}\end{array}\right]$ (3)
 > $\mathrm{evalf}\left(\mathrm{Duration}\left(\mathrm{middle}\right)\right)$
 ${0.7053514739}$ (4)
 > $\mathrm{last_quarter_sec}≔\mathrm{Extract}\left(\mathrm{aud},-0.25\right)$
 ${\mathrm{last_quarter_sec}}{≔}\left[\begin{array}{cc}{"Sample Rate"}& {22050}\\ {"File Format"}& {\mathrm{PCM}}\\ {"File Bit Depth"}& {8}\\ {"Channels"}& {2}\\ {"Samples/Channel"}& {5512}\\ {"Duration"}& {0.24998}{}{s}\end{array}\right]$ (5)
 > $\mathrm{evalf}\left(\mathrm{Duration}\left(\mathrm{last_quarter_sec}\right)\right)$
 ${0.2499773243}$ (6)