Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguos medium-level API #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions main/low/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use std::os::raw::{c_int, c_void};
/// Structs, types and constants defined by REAPER.
pub use super::bindings::root::{
accelerator_register_t, audio_hook_register_t, gaccel_register_t, midi_Input, midi_Output,
midi_realtime_write_struct_t, preview_register_t, reaper_plugin_info_t, IReaperControlSurface,
IReaperPitchShift, KbdCmd, KbdSectionInfo, MIDI_event_t, MIDI_eventlist, MediaItem,
MediaItem_Take, MediaTrack, PCM_sink, PCM_source, PCM_source_peaktransfer_t,
PCM_source_transfer_t, ProjectStateContext, REAPER_Resample_Interface, ReaProject, ReaSample,
TrackEnvelope, WDL_HeapBuf, CSURF_EXT_RESET, CSURF_EXT_SETBPMANDPLAYRATE,
CSURF_EXT_SETFOCUSEDFX, CSURF_EXT_SETFXCHANGE, CSURF_EXT_SETFXENABLED, CSURF_EXT_SETFXOPEN,
CSURF_EXT_SETFXPARAM, CSURF_EXT_SETFXPARAM_RECFX, CSURF_EXT_SETINPUTMONITOR,
CSURF_EXT_SETLASTTOUCHEDFX, CSURF_EXT_SETPAN_EX, CSURF_EXT_SETPROJECTMARKERCHANGE,
CSURF_EXT_SETRECVPAN, CSURF_EXT_SETRECVVOLUME, CSURF_EXT_SETSENDPAN, CSURF_EXT_SETSENDVOLUME,
CSURF_EXT_SUPPORTS_EXTENDED_TOUCH, CSURF_EXT_TRACKFX_PRESET_CHANGED,
PCM_SOURCE_EXT_EXPORTTOFILE, PCM_SOURCE_EXT_GETPOOLEDMIDIID, PCM_SOURCE_EXT_OPENEDITOR,
PCM_SOURCE_EXT_SETPREVIEWTEMPO, REAPER_PITCHSHIFT_API_VER, REAPER_PLUGIN_VERSION,
RESAMPLE_EXT_SETRSMODE, UNDO_STATE_ALL, UNDO_STATE_FREEZE, UNDO_STATE_FX, UNDO_STATE_ITEMS,
UNDO_STATE_MISCCFG, UNDO_STATE_TRACKCFG,
midi_realtime_write_struct_t, preview_register_t, reaper_functions::AudioAccessor,
reaper_plugin_info_t, IReaperControlSurface, IReaperPitchShift, KbdCmd, KbdSectionInfo,
MIDI_event_t, MIDI_eventlist, MediaItem, MediaItem_Take, MediaTrack, PCM_sink, PCM_source,
PCM_source_peaktransfer_t, PCM_source_transfer_t, ProjectStateContext,
REAPER_Resample_Interface, ReaProject, ReaSample, TrackEnvelope, WDL_HeapBuf, CSURF_EXT_RESET,
CSURF_EXT_SETBPMANDPLAYRATE, CSURF_EXT_SETFOCUSEDFX, CSURF_EXT_SETFXCHANGE,
CSURF_EXT_SETFXENABLED, CSURF_EXT_SETFXOPEN, CSURF_EXT_SETFXPARAM, CSURF_EXT_SETFXPARAM_RECFX,
CSURF_EXT_SETINPUTMONITOR, CSURF_EXT_SETLASTTOUCHEDFX, CSURF_EXT_SETPAN_EX,
CSURF_EXT_SETPROJECTMARKERCHANGE, CSURF_EXT_SETRECVPAN, CSURF_EXT_SETRECVVOLUME,
CSURF_EXT_SETSENDPAN, CSURF_EXT_SETSENDVOLUME, CSURF_EXT_SUPPORTS_EXTENDED_TOUCH,
CSURF_EXT_TRACKFX_PRESET_CHANGED, PCM_SOURCE_EXT_EXPORTTOFILE, PCM_SOURCE_EXT_GETPOOLEDMIDIID,
PCM_SOURCE_EXT_OPENEDITOR, PCM_SOURCE_EXT_SETPREVIEWTEMPO, REAPER_PITCHSHIFT_API_VER,
REAPER_PLUGIN_VERSION, RESAMPLE_EXT_SETRSMODE, UNDO_STATE_ALL, UNDO_STATE_FREEZE,
UNDO_STATE_FX, UNDO_STATE_ITEMS, UNDO_STATE_MISCCFG, UNDO_STATE_TRACKCFG,
};

/// Structs, types and constants defined by `swell.h` (on Linux and Mac OS X) and
Expand Down
24 changes: 24 additions & 0 deletions main/medium/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,27 @@ pub enum SetTrackUiFlags {
PreventTrackGrouping = 1,
PreventSelectionGanging = 2,
}

/// Defines nudge mode in `apply_nudge`
///
/// if not SetToValue — will nudge by value.
#[enumflags2::bitflags]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum ApplyNudgeFlag {
SetToValue = 1,
Snap = 2,
}

/// Defines how project is saved in `Reaper::save_project_ex()`
#[enumflags2::bitflags]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[repr(u32)]
pub enum SaveProjectFlags {
/// Save as RTrackTemplate.
AsTrackTemplate = 1,
/// Include media in track template.
WithMedia = 2,
/// Include envelopes in track template.
WithEnvelopes = 4,
}
144 changes: 144 additions & 0 deletions main/medium/src/misc_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,3 +1664,147 @@ impl InsertMediaMode {
bits as i32
}
}

/// Defines, in which units nudge will be applied.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub enum NudgeUnits {
Milliseconds,
Seconds,
Grid,
Notes256,
Notes128,
Notes64,
Notes32,
Notes16,
Notes8,
Notes4,
Notes2,
NotesWhole,
/// (1.15 = 1 measure + 1.5 beats)
MeasuresBeats,
Samples,
Frames,
Pixels,
ItemLength,
ItemSelections,
}

impl NudgeUnits {
/// Converts this value to an integer as expected by the low-level API.
pub fn to_raw(self) -> i32 {
match self {
Self::Milliseconds => 0,
Self::Seconds => 1,
Self::Grid => 2,
Self::Notes256 => 3,
Self::Notes128 => 4,
Self::Notes64 => 5,
Self::Notes32 => 6,
Self::Notes16 => 7,
Self::Notes8 => 8,
Self::Notes4 => 9,
Self::Notes2 => 10,
Self::NotesWhole => 15,
Self::MeasuresBeats => 16,
Self::Samples => 17,
Self::Frames => 18,
Self::Pixels => 19,
Self::ItemLength => 20,
Self::ItemSelections => 21,
}
}
}

/// Selects string information, that can be set or retrieved from project.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub enum ProjectInfoStringCategory {
/// Project file name (read-only, is_set will be ignored).
ProjectName,

/// Title field from Project Settings/Notes dialog
ProjectTitle,

/// Author field from Project Settings/Notes dialog
ProjectAuthor,

/// Track group name, value should be 1..64
TrackGroupName(u8),

/// Get the GUID (unique ID) of the marker or region with given index,
/// index is the one, that passed to `enum_project_markers`,
/// not necessarily the displayed number.
MarkerGuid(u32),

/// Recording directory -- may be blank or a relative path,
/// to get the effective path see get_project_path_ex()
RecordPath,

/// Secondary recording directory.
RecordPathSecondary,

/// Render directory
RenderFile,

/// Render file name (may contain wildcards)
RenderPattern,

/// The metadata saved with the project
/// (not metadata embedded in project media).
///
/// # Example ID3 album name metadata:
///
/// value=ReaperStringArg::from("ID3:TALB") to get
/// value=ReaperStringArg::from("ID3:TALB|my album name") to set.
///
/// Returns as a semicolon-separated list of defined project metadata identifiers.
RenderMetadata,

/// Semicolon separated list of files that would be written
/// if the project is rendered using the most recent render settings.
RenderTargets,

/// (read-only) semicolon separated list of statistics
/// for the most recently rendered files.
/// Call with value=ReaperStringArg::from("XXX") to run an action
/// (for example, "42437"=dry run render selected items) before returning statistics.
RenderStats,

/// base64-encoded sink configuration (see project files, etc).
///
/// Callers can also pass a simple 4-byte string (non-base64-encoded),
/// e.g. "evaw" or "l3pm", to use default settings for that sink type.
///
/// Generate ReaScriptAPI from the REAPER to see which formats are supported
/// and retrieve their strings.
///
/// Typical are: "wave" "aiff" "caff" "iso " "ddp " "flac" "mp3l" "oggv"
/// "OggS" "FFMP" "WMF " "GIF " "LCF " "wvpk"
RenderFormat,

/// See RenderFormat
RenderFormat2,
}

impl<'a> ProjectInfoStringCategory {
/// Converts this value to an &str as expected by the low-level API.
pub fn to_raw(self) -> ReaperStringArg<'a> {
match self {
Self::ProjectName => ReaperStringArg::from("PROJECT_NAME"),
Self::ProjectTitle => ReaperStringArg::from("PROJECT_TITLE"),
Self::ProjectAuthor => ReaperStringArg::from("PROJECT_AUTHOR"),
Self::TrackGroupName(val) => {
ReaperStringArg::from(format!("TRACK_GROUP_NAME:{:?}", val))
}
Self::MarkerGuid(val) => ReaperStringArg::from(format!("MARKER_GUID:{:?}", val)),
Self::RecordPath => ReaperStringArg::from("RECORD_PATH"),
Self::RecordPathSecondary => ReaperStringArg::from("RECORD_PATH_SECONDARY"),
Self::RenderFile => ReaperStringArg::from("RENDER_FILE"),
Self::RenderPattern => ReaperStringArg::from("RENDER_PATTERN"),
Self::RenderMetadata => ReaperStringArg::from("RENDER_METADATA"),
Self::RenderTargets => ReaperStringArg::from("RENDER_TARGETS"),
Self::RenderStats => ReaperStringArg::from("RENDER_STATS"),
Self::RenderFormat => ReaperStringArg::from("RENDER_FORMAT"),
Self::RenderFormat2 => ReaperStringArg::from("RENDER_FORMAT2"),
}
}
}
2 changes: 2 additions & 0 deletions main/medium/src/ptr_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub type MediaItem = NonNull<raw::MediaItem>;
pub type MediaItemTake = NonNull<raw::MediaItem_Take>;
/// Pointer to an envelope on a track.
pub type TrackEnvelope = NonNull<raw::TrackEnvelope>;
/// Pointer to an audio accessor on track or take.
pub type AudioAccessor = NonNull<raw::AudioAccessor>;
/// Pointer to a window (window handle).
pub type Hwnd = NonNull<raw::HWND__>;
/// Pointer to a module/instance (module/instance handle).
Expand Down
Loading