session¶
This module is responsible for maintaining the current state of the loop, such as the current beat, bar and track
states.
Big parts use asyncio so that functions can be handled asynchronously.
- class backlooper.session.Session(bpm: float, audio: AudioStream)¶
Bases:
objectThe
Sessionobject is responsible for maintaining the current state of the loop, such as the current beat, bar and track states. The underlying audio is delegated to theaudioobject.- audio: AudioStream¶
Manages the audio stream and interface.
- bpm: float¶
Tempo of the session in beats per minute.
- async calibrate()¶
Executes the calibration routine to determine round-trip latency.
- async click()¶
Sends updates to the frontend about the current beat. Loops indefinitely.
- register_websocket(websocket: WebSocketServerProtocol)¶
Stores the websocket for communication towards the frontend.
- async request_recording(track_id: int, bars_to_record: int)¶
Records the previous
bars_to_recordbars for tracktrack_idand starts playing.
- async reset()¶
Resets all tracks to their starting state.
- run()¶
Main starting point of a session.
- async send_calibration_diagram(message: str)¶
Sends the calibration diagram to the frontend.
- async send_latency_update()¶
Sends the currently configured latency to the frontend.
- async send_tracks_update()¶
Sends the current state of all tracks to the frontend.
- async set_bpm(bpm: int)¶
Updates the tempo.
- async start_playing(track_id: int)¶
Starts playing a track
track_idfor which recording already has taken place.
- async stop_playing(track_id: int)¶
Stops playing a track
track_id.
- class backlooper.session.Track(track_id: int, start_timestamp: float | None = None, end_timestamp: float | None = None, state: TrackState = TrackState.EMPTY)¶
Bases:
objectA track can contain looped audio. Tracks are identified by their
track_id. If the track is looping, thestart_timestampandend_timestampwill be filled.- end_timestamp: float | None = None¶
- start_timestamp: float | None = None¶
- state: TrackState = 'EMPTY'¶
- track_id: int¶
- class backlooper.session.TrackState(value)¶
Bases:
str,EnumTrackStatecontains all possible track states. Tracks start out empty, and proceed through further states during the session.- EMPTY = 'EMPTY'¶
- PLAYING = 'PLAYING'¶
- RECORDING = 'RECORDING'¶
- STOPPED = 'STOPPED'¶
- STOPPING = 'STOPPING'¶
- TRIGGERED = 'TRIGGERED'¶