Skip to content

Class Documentation

Josh Pinto edited this page Jul 22, 2025 · 8 revisions

๐Ÿ”– Explanation of Organization

The following descriptors/headers are used to organize the methods and variables applicable to each class detailed in this documentation file.

  • ๐Ÿ†• Instantiation: how to create a new instance of the class.
  • ๐Ÿ’ฌ Exposed Variables: declared upon object initialization and can be read/modified.
  • โš™๏ธ Configuration Methods: generally unimportant setup/debugging methods
  • ๐Ÿ“ Action Methods: modify values or relay instructions
  • ๐Ÿ”ฎ Request Methods: return information from a device/variable

๐ŸŽธ LtAmpBase

The LtAmpBase class contains the key, shared methods and configuration options that exist between both the synchronous and asynchronous child classes, which are documented below.

๐Ÿ†• Instantiation

Instead of instantiating LtAmpBase, you should instantiate one of its child-classes: LtAmpSync or LtAmp

๐Ÿ’ฌ Exposed Variables

device

Instance of HidDevice typically set by connect(). Can be set externally to any compatible object.

hid_wrapper

An instance of HidWrapper declared for each LtAmpBase-inheriting class, this can be accessed in instances where HidWrapping functionality needs to be altered or customized. LtAmpBase's self.debug is passed through to the HidWrapper

debug

Whether received input data from the amp should be printed

timeout

The max amoount of time given for requests to be returned by the amp. Can be specified during instantiation also.

โš™๏ธ Configuration Methods

Both classes inherit the same key setup methods from LtAmpBase

find_amp()

Returns the first found device (HidDevice) or None if none found.

connect()

Finds the first enumerable amp, opens it (and assigns it to self.device), and sets up _process_input_data as the amp input callback. If successful, returns True, otherwise, raises an error.

disconnect()

Stops the input thread and closes the self.device's HidDevice.

send_message()

Sends a (potentially multi-packet) protobuf message to the amp (self.device)

send_heartbeat()

Important

A heartbeat must be sent every 1 second to maintain the connection.

Sends a heartbeat request to the amp.

send_sync_begin()

In order to begin receiving data from the amp, you should send the SYNC_BEGIN request shortly followed by a SYNC_END message (0.2-1 second delay will work).

send_sync_end()

Finalizes the symbolic sync process with the amp.

๐Ÿ“ Action Methods

All current action methods (setting/pushing information to an amp) are common between synchronous/asynchronous child-classes.

set_preset(preset_index: int)

Sets the active preset to the index specified.

set_qa_slots(slots: list)

Takes a list of integers and sets the footswitch preset quick access slots (list size must be 2!)

audition_preset(preset_json: str)

Takes a JSON preset string (docs coming soon!) and tells the amp to begin auditioning it.

exit_audition()

Closes the audition state and returns to previous preset/modal state.

set_usb_gain(gain: float)

Send a floating point gain value between -15.0 and 15.0 dB which will be configured as the gain value used for USB connections.

๐Ÿ”ฎ Request Methods

N/A: All request methods are declared in LtAmp and LtAmpAsync respectively.

๐Ÿซธ LtAmp

The LtAmp class (aka LtAmpSync.py) is based on the LtAmpBase class and implements the primary mehtods synchronously.

๐Ÿ†• Instantiation

All instantiation arguments are optional and default to the values shown below.

amp = LtAmp(debug=False, timeout=2.0)

๐Ÿ’ฌ Exposed Variables

The LtAmp (synchronous) class has no additional variables not preset in the base class.

โš™๏ธ Configuration Methods

All configuration methods are inherited from LtAmpBase.

๐Ÿ“ Action Methods

All action methods are also inherited from LtAmpBase.

๐Ÿ”ฎ Request Methods

request_connection_status()

Returns True or False based on whether the current self.device is connected.

request_current_preset()

Returns the current preset index or raises an error.

request_firmware_version()

Returns the self.device amp's firmware's version name or raises an error.

request_qa_slots()

Returns a list (with size 2) of preset indices or raises error.

request_audition_state()

Returns a boolean reflecting whether amp is currently auditioning or an error.

request_memory_usage()

Returns a dictionary with keys "stack" and "heap" containing memory values or raises error.

request_processor_utilization()

Returns a dictionary with keys "percent", "minPercent", and "maxPercent" floating-point values or raises an error.

request_usb_gain()

Returns usb gain value between -15.0 and 15.0 or raises error.

request_footswitch_mode()

Supported by only LT4 amps, footswitch mode is returned or error is raised.

request_product_id()

Returns a string product name for the connected device or raises an error.

๐Ÿงต LtAmpAsync

An asynchronous version of the LtAmp class.

๐Ÿ†• Instantiation

Note that all instantiation arguments are optional and default to the values shown below.

amp = LtAmpAsync(debug=False, timeout=2.0)

๐Ÿ’ฌ Exposed Variables

all ltampbase variables are inherited with the addition of:

loop

returns and can be set to a asyncio event loop

โš™๏ธ Configuration Methods

All configuration methods are inherited from LtAmpBase.

๐Ÿ“ Action Methods

All action methods are also inherited from LtAmpBase.

๐Ÿ”ฎ Request Methods

All methods are the same as in LtAmp with the modification of being asyncio wait-ed-_for and asynchronous.

๐ŸŒฏ HidWrapper

A wrapped class for HID USB devices which supports Windows, Linux, and (probably) MacOS.

Note

This class is largely independent of LtAmp library and may be eventually spun-off into a separate module. However, I found it necessary because I couldn't get any pre-existing hid library to work consistently across platforms.

๐Ÿ†• Instantiation

Creates a new HidWrapper, assigning the self.backend and self.hid_lib variables based on the detected platform's respective HID module (pywinusb for Windows and hidapi for Linux/MacOS).

hid_wrapper = HidWrapper(debug=False)

๐Ÿ’ฌ Exposed Variables

backend

String value of either "hidapi"

hid_lib

Actual object instance of either pywinusb.hid or hid (from hidapi).

debug

Whether debug logs should be printed for HID device writes.

โš™๏ธ Configuration Methods

N/A: self._setup_hid_library is auto-called by self.__init__ but should ideally not be messed with.

๐Ÿ“ Action Methods

open_device(device_info)

๐Ÿ”ฎ Request Methods

enumerate_devices()

Returns a list of hid devices found.

๐Ÿ”Œ HidDevice

A unified interface for dealing with a particular HID USB device which can be opened and have data written to and read from.

๐Ÿ†• Instantiation

device = HIDDevice(self.hid_lib.device(), backend=lib, debug=False)

๐Ÿ’ฌ Exposed Variables

device

Set to a HID lib's device object by self.__init__.

backend

Either "hidapi" or "pywinusb" depending on platform. Determines how data is written.

debug

Whether or not debug messages should be printed for data received.

input_callback

Callback function for when data is received from USB HID device.

โš™๏ธ Configuration Methods

set_input_callback(callback)

Sets a function (with a data parameter) to be called when new data is read from the HID USB device.

๐Ÿ“ Action Methods

write(data)

Writes data to HID USB device.

close()

Closes device connection, opening it to be used by other applications/services.

๐Ÿ”ฎ Request Methods

read(length=64, timeout_ms=100)

Warning

This method is for HidAPI Only!

Can be used to read a specified amount of data over a specified time interval from the HID device.

Clone this wiki locally