WIP: Preparing the codebase, nothing important
Some checks failed
ci/woodpecker/push/code_tests Pipeline failed
ci/woodpecker/push/pre_commit_test Pipeline failed

This commit is contained in:
2025-11-22 20:31:38 +01:00
committed by Nikolai Rodionov
parent 213c5b1a47
commit 87ee669502
35 changed files with 2830 additions and 10 deletions

16
lib/Cargo.toml Normal file
View File

@@ -0,0 +1,16 @@
[package]
name = "lib"
version = "0.1.0"
edition = "2024"
[dependencies]
prost = "0.14.1"
tokio = { version = "1.48.0", features = ["rt-multi-thread"] }
tonic = "0.14.2"
tonic-prost = "0.14.2"
uuid = { version = "1.18.1", features = ["v4"] }
[build-dependencies]
prost-build = "0.14.1"
prost-types = "0.14.1"
tonic-prost-build = "0.14.2"

29
lib/build.rs Normal file
View File

@@ -0,0 +1,29 @@
use std::{env, fs, io::Result, path::PathBuf};
fn main() -> Result<()> {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
//let proto_dir = "proto";
//let paths = fs::read_dir(proto_dir).unwrap();
//for path in paths {
// let path_str = path.unwrap().path().to_str().unwrap().to_string();
// let descriptor = format!("{}_descriptor.bin", path_str);
// tonic_prost_build::configure()
// .file_descriptor_set_path(out_dir.join("audio_backend_descriptor.bin"))
// .compile_protos(&["proto/audio_backend.proto"], &["proto"])
// .unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
//}
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_prost_build::configure()
.file_descriptor_set_path(out_dir.join("audio_backend_descriptor.bin"))
.compile_protos(&["proto/audio_backend.proto"], &["proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
tonic_prost_build::configure()
.file_descriptor_set_path(out_dir.join("track_descriptor.bin"))
.compile_protos(&["proto/track.proto"], &["proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
Ok(())
}

View File

@@ -0,0 +1,49 @@
syntax = "proto3";
package termix.audio_backend;
import "google/protobuf/empty.proto";
service AudioBackendRPC {
// Stop the active audio server
rpc StopClient(google.protobuf.Empty) returns (google.protobuf.Empty);
// Start the audio server of choice
rpc StartClient(DesiredAudioBacked) returns (google.protobuf.Empty);
// Get information about the possible audio backend configuration options
rpc DescribeBackend(DesiredAudioBacked) returns (AudioBackendDescription);
rpc InitConnection(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc GetAvailableBackends(google.protobuf.Empty) returns (BackendList);
}
enum SupportedAudioBackends {
AB_UNSPECIFIED = 0;
AB_JACK = 1;
AB_COREAUDIO = 2;
}
message DesiredAudioBacked {
SupportedAudioBackends backend = 1;
CoreAudioOptions core_audio_opts = 2;
}
message AudioBackendDescription {
CoreAudioAvailableOptions core_audio_description = 1;
repeated string input_devices = 2;
repeated string output_devices = 3;
}
message CoreAudioAvailableOptions {
repeated string input_devices = 1;
repeated string output_devices = 2;
}
message CoreAudioOptions {
string input_device = 1;
}
message BackendList {
repeated Backend backends = 1;
}
message Backend {
string name = 1;
}

19
lib/proto/track.proto Normal file
View File

@@ -0,0 +1,19 @@
syntax = "proto3";
package termix.track;
import "google/protobuf/empty.proto";
service TrackOp {
rpc Create(Track) returns (google.protobuf.Empty);
rpc List(google.protobuf.Empty) returns (Tracks);
}
message Track {
string name = 1;
}
message Tracks {
repeated Track tracks = 1;
}

7
lib/src/lib.rs Normal file
View File

@@ -0,0 +1,7 @@
pub mod termix {
pub mod audio_backend {
pub const FILE_DESCRIPTOR_SET: &[u8] =
tonic::include_file_descriptor_set!("audio_backend_descriptor");
tonic::include_proto!("termix.audio_backend");
}
}

25
lib/src/metadata.rs Normal file
View File

@@ -0,0 +1,25 @@
use uuid::Uuid;
pub struct Metadata {
id: Uuid,
name: String,
}
impl Metadata {
pub fn new(name: String) -> Self {
let id = Uuid::new_v4();
Self { id, name }
}
pub fn id(&self) -> Uuid {
self.id
}
pub fn name(&self) -> &str {
&self.name
}
pub fn set_name(&mut self, name: String) {
self.name = name;
}
}

9
lib/src/project.rs Normal file
View File

@@ -0,0 +1,9 @@
use crate::{metadata::Metadata, region::Region, track::Track};
pub struct Project {
pub name: String,
pub tracks: Option<Vec<Track>>,
pub regions: Option<Vec<Region>>,
// Current playhead position
pub current_sample: u64,
}

11
lib/src/region.rs Normal file
View File

@@ -0,0 +1,11 @@
use crate::metadata::Metadata;
pub struct Region {
pub metadata: Metadata,
// Position of the track on the track
pub starts_at: u64,
// From which point of the audio source the region starts
pub plays_from: u64,
// Duration of the region after plays_from
pub duration: u64,
}

14
lib/src/track.rs Normal file
View File

@@ -0,0 +1,14 @@
use crate::metadata::Metadata;
pub enum TrackType {
Audio,
Midi,
}
pub struct Track {
pub metadata: Metadata,
pub track_type: TrackType,
pub active: bool,
}
pub struct TrackStatus {}