Module pcm
Provide implementation for PCM functions.
Info:
- License: MIT
- Author: Nomad Monad
ReaWrap Custom Methods
| PCM:new (source) | Create new PCM instance. |
| PCM:log (...) | Log messages with the PCM logger. |
ReaScript Wrapped Methods
ReaWrap Custom Methods
- PCM:new (source)
-
Create new PCM instance.
Parameters:
- source userdata The pointer to PCM_source*
Returns:
-
table PCM object
- PCM:log (...)
-
Log messages with the PCM logger.
Parameters:
- ... (varargs) Messages to log.
ReaScript Wrapped Methods
- PCM:calc_media_src_loudness ()
-
Calc Media Src Loudness. Wraps CalcMediaSrcLoudness.
Calculates loudness statistics of media via dry run render. Statistics will be
displayed to the user; call GetSetProjectInfo_String("RENDER_STATS") to retrieve
via API. Returns 1 if loudness was calculated successfully, -1 if user canceled
the dry run render.
Returns:
-
number
- PCM:calculate_normalization (normalize_to, normalize_target, normalize_start, normalize_end)
-
Calculate Normalization. Wraps CalculateNormalization.
Calculate normalize adjustment for source media. normalizeTo: 0=LUFS-I, 1=RMS-I,
2=peak, 3=true peak, 4=LUFS-M max, 5=LUFS-S max. normalizeTarget: dBFS or LUFS
value. normalizeStart, normalizeEnd: time bounds within source media for
normalization calculation. If normalizationStart=0 and normalizationEnd=0, the
full duration of the media will be used for the calculation.
Parameters:
- normalize_to number
- normalize_target number
- normalize_start number
- normalize_end number
Returns:
-
number
- PCM:get_media_file_metadata (identifier)
-
Get Media File Metadata. Wraps GetMediaFileMetadata.
Get text-based metadata from a media file for a given identifier. Call with
identifier="" to list all identifiers contained in the file, separated by
newlines. May return "[Binary data]" for metadata that REAPER doesn't handle.
Parameters:
- identifier string
Returns:
-
string buf
- PCM:get_media_source_file_name ()
-
Get Media Source File Name. Wraps GetMediaSourceFileName.
Copies the media source filename to filename buf. Note that in-project MIDI media
sources have no associated filename. See GetMediaSourceParent.
Returns:
-
string
- PCM:get_media_source_length ()
-
Get Media Source Length. Wraps GetMediaSourceLength.
Returns the length of the source media. If the media source is beat-based, the
length will be in quarter notes, otherwise it will be in seconds.
Returns:
-
boolean length_is_qn
- PCM:get_media_source_num_channels ()
-
Get Media Source Num Channels. Wraps GetMediaSourceNumChannels.
Returns the number of channels in the source media.
Returns:
-
number
- PCM:get_media_source_parent ()
-
Get Media Source Parent. Wraps GetMediaSourceParent.
Returns the parent source, or NULL if src is the root source. This can be used
to retrieve the parent properties of sections or reversed sources for example.
Returns:
-
table PCM object
- PCM:get_media_source_sample_rate ()
-
Get Media Source Sample Rate. Wraps GetMediaSourceSampleRate.
Returns the sample rate. MIDI source media will return zero.
Returns:
-
number
- PCM:get_media_source_type ()
-
Get Media Source Type. Wraps GetMediaSourceType.
copies the media source type ("WAV", "MIDI", etc) to typebuf
Returns:
-
string
- PCM:get_sub_project_from_source ()
-
Get Sub Project From Source. Wraps GetSubProjectFromSource.
Returns:
-
table Project object
- PCM:get_tempo_match_play_rate (src_scale, position, mult)
-
Get Tempo Match Play Rate. Wraps GetTempoMatchPlayRate.
finds the play rate and target length to insert this item stretched to a round
power-of-2 number of bars, between 1/8 and 256.
Parameters:
- src_scale number
- position number
- mult number
Returns:
- number rate
- number targetlen
- PCM:sink_enum (idx)
-
Sink Enum. Wraps PCM_Sink_Enum.
Parameters:
- idx number
Returns:
-
string
- PCM:sink_get_extension (data)
-
Sink Get Extension. Wraps PCM_Sink_GetExtension.
Parameters:
- data string
Returns:
-
string
- PCM:sink_show_config (cfg, hwnd_parent)
-
Sink Show Config. Wraps PCM_Sink_ShowConfig.
Parameters:
- cfg string
- hwnd_parent userdata HWND
Returns:
-
userdata HWND
- PCM:source_build_peaks (mode)
-
Source Build Peaks. Wraps PCM_Source_BuildPeaks.
Calls and returns PCM_source::PeaksBuild_Begin() if mode=0, PeaksBuild_Run() if
mode=1, and PeaksBuild_Finish() if mode=2. Normal use is to call
PCM_Source_BuildPeaks(src,0), and if that returns nonzero, call
PCM_Source_BuildPeaks(src,1) periodically until it returns zero (it returns the
percentage of the file remaining), then call PCM_Source_BuildPeaks(src,2) to
finalize. If PCM_Source_BuildPeaks(src,0) returns zero, then no further action
is necessary.
Parameters:
- mode number
Returns:
-
number
- PCM:source_create_from_file (file_name)
-
Source Create From File. Wraps PCM_Source_CreateFromFile.
See PCM_Source_CreateFromFileEx.
Parameters:
- file_name string
Returns:
-
table PCM object
- PCM:source_create_from_file_ex (file_name, forceno_midi_imp)
-
Source Create From File Ex. Wraps PCM_Source_CreateFromFileEx.
Create a PCM_source from filename, and override pref of MIDI files being
imported as in-project MIDI events.
Parameters:
- file_name string
- forceno_midi_imp boolean
Returns:
-
table PCM object
- PCM:source_create_from_type (source_type)
-
Source Create From Type. Wraps PCM_Source_CreateFromType.
Create a PCM_source from a "type" (use this if you're going to load its state
via LoadState/ProjectStateContext). Valid types include "WAVE", "MIDI", or
whatever plug-ins define as well.
Parameters:
- source_type string
Returns:
-
table PCM object
- PCM:source_destroy ()
- Source Destroy. Wraps PCM_Source_Destroy. Deletes a PCM_source -- be sure that you remove any project reference before deleting a source
- PCM:source_get_peaks (peakrate, starttime, numchannels, numsamplesperchannel, want_extra_type, buf)
-
Source Get Peaks. Wraps PCM_Source_GetPeaks.
Gets block of peak samples to buf. Note that the peak samples are interleaved,
but in two or three blocks (maximums, then minimums, then extra). Return value
has 20 bits of returned sample count, then 4 bits of output_mode (0xf00000),
then a bit to signify whether extra_type was available (0x1000000). extra_type
can be 115 ('s') for spectral information, which will return peak samples as
integers with the low 15 bits frequency, next 14 bits tonality.
Parameters:
- peakrate number
- starttime number
- numchannels number
- numsamplesperchannel number
- want_extra_type number
- buf userdata
Returns:
-
number
- PCM:source_get_section_info ()
-
Source Get Section Info. Wraps PCM_Source_GetSectionInfo.
If a section/reverse block, retrieves offset/len/reverse.
Returns:
- number offs
- number len
- boolean rev
- PCM:create_preview ()
-
Create Preview. Wraps CF_CreatePreview.
Create a new preview object. Does not take ownership of the source (don't forget
to destroy it unless it came from a take!). See CF_Preview_Play and the others
CF_Preview_* functions.
Returns:
-
userdata
- PCM:enum_media_source_cues (index)
-
Enum Media Source Cues. Wraps CF_EnumMediaSourceCues.
Enumerate the source's media cues. Returns the next index or 0 when finished.
Parameters:
- index number
Returns:
- number time
- number end_time
- boolean is_region
- string name
- boolean is_chapter
- PCM:export_media_source (file_name)
-
Export Media Source. Wraps CF_ExportMediaSource.
Export the source to the given file (MIDI only).
Parameters:
- file_name string
Returns:
-
boolean
- PCM:get_media_source_bit_depth ()
-
Get Media Source Bit Depth. Wraps CF_GetMediaSourceBitDepth.
Returns the bit depth if available (0 otherwise).
Returns:
-
number
- PCM:get_media_source_bit_rate ()
-
Get Media Source Bit Rate. Wraps CF_GetMediaSourceBitRate.
Returns the bit rate for WAVE (wav, aif) and streaming/variable formats (mp3,
ogg, opus). REAPER v6.19 or later is required for non-WAVE formats.
Returns:
-
number
- PCM:get_media_source_metadata (name, out)
-
Get Media Source Metadata. Wraps CF_GetMediaSourceMetadata.
Get the value of the given metadata field (eg. DESC, ORIG, ORIGREF, DATE, TIME,
UMI, CODINGHISTORY for BWF).
Parameters:
- name string
- out string
Returns:
-
string
- PCM:get_media_source_online ()
-
Get Media Source Online. Wraps CF_GetMediaSourceOnline.
Returns the online/offline status of the given source.
Returns:
-
boolean
- PCM:get_media_source_rpp ()
-
Get Media Source Rpp. Wraps CF_GetMediaSourceRPP.
Get the project associated with this source (BWF, subproject...).
Returns:
-
string
- PCM:source_set_section_info (section, offset, length, reverse, fade_in)
-
Source Set Section Info. Wraps CF_PCM_Source_SetSectionInfo.
Give a section source created using PCM_Source_CreateFromType("SECTION"). Offset
and length are ignored if 0. Negative length to subtract from the total length
of the source.
Parameters:
- section userdata PCM_source*
- offset number
- length number
- reverse boolean
- fade_in number Optional
Returns:
-
boolean
- PCM:set_media_source_online (set)
-
Set Media Source Online. Wraps CF_SetMediaSourceOnline.
Set the online/offline status of the given source (closes files when set=false).
Parameters:
- set boolean
- PCM:source_get_sample_value (time)
-
Source Get Sample Value. Wraps GU_PCM_Source_GetSampleValue.
Gets a PCM_source's sample value at a point in time (seconds).
Parameters:
- time number
Returns:
-
number
- PCM:source_has_region ()
-
Source Has Region. Wraps GU_PCM_Source_HasRegion.
Checks if PCM_source has embedded Media Cue Markers.
Returns:
-
boolean
- PCM:source_is_mono ()
-
Source Is Mono. Wraps GU_PCM_Source_IsMono.
Checks if PCM_source is mono by comparing all channels
Returns:
-
boolean
- PCM:source_time_to_peak (buffer_size, threshold)
-
Source Time To Peak. Wraps GU_PCM_Source_TimeToPeak.
Returns duration in seconds for PCM_source from start til peak threshold is
breached. Returns -1 if invalid.
Parameters:
- buffer_size number
- threshold number
Returns:
-
number
- PCM:source_time_to_peak_r (buffer_size, threshold)
-
Source Time To Peak R. Wraps GU_PCM_Source_TimeToPeakR.
Returns duration in seconds for PCM_source from end til peak threshold is
breached in reverse. Returns -1 if invalid.
Parameters:
- buffer_size number
- threshold number
Returns:
-
number
- PCM:source_time_to_rms (buffer_size, threshold)
-
Source Time To RMS. Wraps GU_PCM_Source_TimeToRMS.
Returns duration in seconds for PCM_source from start til RMS threshold is
breached. Returns -1 if invalid.
Parameters:
- buffer_size number
- threshold number
Returns:
-
number
- PCM:source_time_to_rms_reversed (buffer_size, threshold)
-
Source Time To RMS Reversed. Wraps GU_PCM_Source_TimeToRMSR.
Returns duration in seconds for PCM_source from end til RMS threshold is
breached in reverse. Returns -1 if invalid.
Parameters:
- buffer_size number
- threshold number
Returns:
-
number
- PCM:get_media_source_samples (dest_buf, dest_buf_offset, num_frames, num_chans, samplerate, source_position)
-
Get Media Source Samples. Wraps Xen_GetMediaSourceSamples.
Get interleaved audio data from media source.
Parameters:
- dest_buf userdata
- dest_buf_offset number
- num_frames number
- num_chans number
- samplerate number
- source_position number
Returns:
-
number
- PCM:start_source_preview (gain, loop, output_chain_idx)
-
Start Source Preview. Wraps Xen_StartSourcePreview.
Start audio preview of a PCM_source. Returns id of a preview handle that can be
provided to Xen_StopSourcePreview. If the given PCM_source does not belong to an
existing MediaItem/Take, it will be deleted by the preview system when the
preview is stopped.
Parameters:
- gain number
- loop boolean
- output_chain_idx number Optional
Returns:
-
number