TsHapticPlayer
teslasuit_sdk.subsystems.ts_haptic.TsHapticPlayer
Controls haptic playback for a single TESLASUIT device.
Manages a queue of playable haptic assets and instant touch events, and exposes per-player and per-playable state controls such as pause, mute, loop, and parameter multipliers.
Methods#
__init__#
def __init__(device):
Initialize the haptic player for a specific device.
Parameters
device
Device handle (pointer to TsDeviceHandle).
is_player_running#
def is_player_running() -> bool:
Check whether the haptic player is currently running.
Returns: bool
True if the player is running.
stop_player#
def stop_player() -> None:
Stop the haptic player for the device.
is_player_paused#
def is_player_paused() -> bool:
Check whether the haptic player is currently paused.
Returns: bool
True if the player is paused.
set_player_paused#
def set_player_paused(is_paused: bool) -> None:
Pause or resume the haptic player.
Parameters
is_paused: bool
True to pause the player, False to resume.
is_player_muted#
def is_player_muted() -> bool:
Check whether the haptic player is currently muted.
Returns: bool
True if the player is muted.
set_player_muted#
def set_player_muted(is_muted: bool) -> None:
Mute or unmute the haptic player.
Parameters
is_muted: bool
True to mute the player, False to unmute.
get_player_time#
def get_player_time() -> int:
Retrieve the elapsed playback time of the haptic player.
Returns: int
Elapsed time in milliseconds since the player started.
get_number_of_master_multipliers#
def get_number_of_master_multipliers() -> int:
Retrieve the number of master multipliers supported by the haptic player.
Returns: int
Number of master multipliers.
get_master_multipliers#
def get_master_multipliers() -> List[TsHapticParamMultiplier]:
Retrieve all master multipliers for the haptic player.
Returns: list
List of TsHapticParamMultiplier instances.
set_master_multipliers#
def set_master_multipliers(multipliers: List[TsHapticParamMultiplier]) -> None:
Set all master multipliers for the haptic player.
The length of multipliers must equal the value returned by
get_master_multiplier#
def get_master_multiplier(type: TsHapticParamType) -> TsHapticParamMultiplier:
Retrieve the master multiplier for a specific parameter type.
Returns: TsHapticParamMultiplier
The matching multiplier, or a zero-valued multiplier if not found.
set_master_multiplier#
def set_master_multiplier(multiplier: TsHapticParamMultiplier) -> None:
Update a single master multiplier by matching its type.
Parameters
multiplier: TsHapticParamMultiplier
The multiplier to apply; its type field determines which existing multiplier is updated.
create_playable#
def create_playable(asset: int, is_looped: bool) -> int:
Create a haptic playable from a loaded asset.
Parameters
asset: int
Asset handle as returned by TsAssetManager.
is_looped: bool
True to loop the playable continuously.
Returns: int
Identifier of the newly created playable.
is_playable_exists#
def is_playable_exists(playable_id: int) -> bool:
Check whether a playable with the given ID exists in the player.
Parameters
playable_id: int
Playable identifier.
Returns: bool
True if the playable exists.
play_playable#
def play_playable(playable_id: int) -> None:
Start playback of a haptic playable.
Parameters
playable_id: int
Playable identifier.
play_touch#
def play_touch(params: List[TsHapticParam], channels: List[int], duration: int) -> None:
Immediately play a haptic touch with the given parameters and channels.
Parameters
params: List[TsHapticParam]
List of TsHapticParam instances defining the waveform.
channels: List[int]
List of channel handle values to activate.
duration: int
Duration of the touch in milliseconds.
create_touch#
def create_touch(params: List[TsHapticParam], channels: List[int], duration: int) -> int:
Create a haptic touch playable without immediately starting it.
Parameters
params: List[TsHapticParam]
List of TsHapticParam instances defining the waveform.
channels: List[int]
List of channel handle values to activate.
duration: int
Duration of the touch in milliseconds.
Returns: int
Identifier of the newly created playable.
is_playable_playing#
def is_playable_playing(playable_id: int) -> bool:
Check whether a playable is currently playing.
Parameters
playable_id: int
Playable identifier.
Returns: bool
True if the playable is currently playing.
stop_playable#
def stop_playable(playable_id: int) -> None:
Stop a playing haptic playable.
Parameters
playable_id: int
Playable identifier.
remove_playable#
def remove_playable(playable_id: int) -> None:
Remove a playable from the haptic player queue.
Parameters
playable_id: int
Playable identifier.
get_playable_paused#
def get_playable_paused(playable_id: int) -> bool:
Check whether a specific playable is paused.
Parameters
playable_id: int
Playable identifier.
Returns: bool
True if the playable is paused.
set_playable_paused#
def set_playable_paused(playable_id: int, is_paused: bool) -> None:
Pause or resume a specific playable.
Parameters
playable_id: int
Playable identifier.
is_paused: bool
True to pause, False to resume.
get_playable_muted#
def get_playable_muted(playable_id: int) -> bool:
Check whether a specific playable is muted.
Parameters
playable_id: int
Playable identifier.
Returns: bool
True if the playable is muted.
set_playable_muted#
def set_playable_muted(playable_id: int, is_muted: bool) -> None:
Mute or unmute a specific playable.
Parameters
playable_id: int
Playable identifier.
is_muted: bool
True to mute, False to unmute.
get_playable_looped#
def get_playable_looped(playable_id: int) -> bool:
Check whether a specific playable is set to loop.
Parameters
playable_id: int
Playable identifier.
Returns: bool
True if the playable is looped.
set_playable_looped#
def set_playable_looped(playable_id: int, is_looped: bool) -> None:
Enable or disable looping for a specific playable.
Parameters
playable_id: int
Playable identifier.
is_looped: bool
True to loop, False to play once.
get_number_of_playable_multipliers#
def get_number_of_playable_multipliers(playable_id: int) -> int:
Retrieve the number of parameter multipliers for a specific playable.
Parameters
playable_id: int
Playable identifier.
Returns: int
Number of multipliers.
get_playable_multipliers#
def get_playable_multipliers(playable_id: int):
Retrieve all parameter multipliers for a specific playable.
Parameters
playable_id: int
Playable identifier.
Returns: ctypes Array
Array of TsHapticParamMultiplier instances.
set_playable_multipliers#
def set_playable_multipliers(playable_id: int, multipliers: List[TsHapticParamMultiplier]) -> None:
Set all parameter multipliers for a specific playable.
Parameters
playable_id: int
Playable identifier.
multipliers: List[TsHapticParamMultiplier]
List of TsHapticParamMultiplier instances.
get_playable_local_time#
def get_playable_local_time(playable_id: int) -> int:
Retrieve the current local playback position of a playable.
Parameters
playable_id: int
Playable identifier.
Returns: int
Local playback time in milliseconds.
set_playable_local_time#
def set_playable_local_time(playable_id: int, local_time: int) -> None:
Seek a playable to a specific local playback position.
Parameters
playable_id: int
Playable identifier.
local_time: int
Target playback position in milliseconds.
get_playable_duration#
def get_playable_duration(playable_id: int) -> int:
Retrieve the total duration of a playable.
Parameters
playable_id: int
Playable identifier.
Returns: int
Duration of the playable in milliseconds.
clear_all_playables#
def clear_all_playables() -> None:
Remove all playables from the haptic player queue.
add_channel_to_dynamic_playable#
def add_channel_to_dynamic_playable(channel_id, playable_id: int) -> None:
Add a channel to a dynamic haptic playable.
Parameters
channel_id
Channel handle to add.
playable_id: int
Playable identifier.
remove_channel_from_dynamic_playable#
def remove_channel_from_dynamic_playable(channel_id, playable_id: int) -> None:
Remove a channel from a dynamic haptic playable.
Parameters
channel_id
Channel handle to remove.
playable_id: int
Playable identifier.
set_material_channel_impact#
def set_material_channel_impact(channel_id, impact: float, playable_id: int) -> None:
Set the impact value for a channel within a haptic material playable.
Parameters
channel_id
Channel handle to update.
impact: float
Impact value to apply to the channel.
playable_id: int
Playable identifier of the material playable.
create_touch_parameters#
def create_touch_parameters(period_ms: int, amplitude: int, pulse_width: int) -> List[TsHapticParam]:
Build a list of TsHapticParam for a haptic touch waveform.
.. note::
The period_ms argument is expressed in microseconds, not
milliseconds; the _ms suffix is a legacy misnomer. Use
period_us = 1000000 / frequency_hz (e.g. 10000 µs = 100 Hz).
Parameters
period_ms: int
Period of the waveform in microseconds (e.g. 10000 = 100 Hz).
amplitude: int
Amplitude of the waveform, as a percent of the calibrated range (1-100).
pulse_width: int
Pulse width of the waveform in microseconds (10-140 µs).
Returns: list
List of three TsHapticParam instances (period, amplitude, pulse width).
create_touch_multipliers#
def create_touch_multipliers(period_ms_m: float, amplitude_m: float, pulse_width_m: float) -> List[TsHapticParamMultiplier]:
Build a list of TsHapticParamMultiplier for scaling a haptic touch.
Parameters
period_ms_m: float
Multiplier for the period parameter.
amplitude_m: float
Multiplier for the amplitude parameter.
pulse_width_m: float
Multiplier for the pulse width parameter.
Returns: list
List of three TsHapticParamMultiplier instances.
Data Structures#
ts_haptic.TsHapticParam#
C structure representing a single haptic parameter type–value pair.
Fields
type int
Parameter type identifier (see TsHapticParamType).
value int
Raw parameter value.
ts_haptic.TsHapticParamMultiplier#
C structure representing a haptic parameter multiplier.
Used to scale haptic output by multiplying a parameter's base value by a coefficient between 0 and 1.
Fields
type int
Parameter type identifier (see TsHapticParamType).
value float
Multiplier coefficient (0.0–1.0).
Enumerations#
ts_haptic.TsHapticParamType#
Enumeration of haptic parameter types.
Undefined(0): Parameter type not specified.Period(1): Period of the haptic waveform in microseconds (e.g. 10000 = 100 Hz).Amplitude(2): Amplitude of the haptic waveform.PulseWidth(3): Pulse width of the haptic waveform.Temperature(4): Temperature feedback parameter.
Members
Undefined 0
Period 1
Amplitude 2
PulseWidth 3
Temperature 4
