Skip to content

Allow passing PCM data as slices instead of Vec #18

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

Merged
merged 2 commits into from
Nov 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "projectm"
version = "2.0.2"
version = "3.0.0"
edition = "2021"
rust-version = "1.65"
authors = ["AnomieVision <[email protected]>", "Mischa Spiegelmock <[email protected]>"]
description = "Bindings for ProjectM"
license = " LGPL-3.0-or-later"
repository = "https://github.com/projectM-visualizer/projectm-rs" #https://github.com/anomievision/projectm-rs
repository = "https://github.com/projectM-visualizer/projectm-rs"
keywords = ["visualization", "audio", "sound", "projectm"]
categories = ["multimedia", "multimedia::video", "multimedia::audio"]
readme = "README.md"
Expand Down
12 changes: 6 additions & 6 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl Projectm {
unsafe { ffi::projectm_pcm_get_max_samples() }
}

fn pcm_add_float(instance: ProjectMHandle, samples: Vec<f32>, channels: ProjectMChannels) {
fn pcm_add_float(instance: ProjectMHandle, samples: &[f32], channels: ProjectMChannels) {
assert!(
samples.len() <= Self::pcm_get_max_samples() as usize,
"Number of samples is greater than max samples"
Expand All @@ -386,7 +386,7 @@ impl Projectm {
}
}

fn pcm_add_int16(instance: ProjectMHandle, samples: Vec<i16>, channels: ProjectMChannels) {
fn pcm_add_int16(instance: ProjectMHandle, samples: &[i16], channels: ProjectMChannels) {
assert!(
samples.len() <= Self::pcm_get_max_samples() as usize,
"Number of samples is greater than max samples"
Expand All @@ -402,7 +402,7 @@ impl Projectm {
}
}

fn pcm_add_uint8(instance: ProjectMHandle, samples: Vec<u8>, channels: ProjectMChannels) {
fn pcm_add_uint8(instance: ProjectMHandle, samples: &[u8], channels: ProjectMChannels) {
assert!(
samples.len() <= Self::pcm_get_max_samples() as usize,
"Number of samples is greater than max samples"
Expand Down Expand Up @@ -762,23 +762,23 @@ impl ProjectM {
Projectm::pcm_get_max_samples()
}

pub fn pcm_add_float(&self, samples: Vec<f32>, channels: ProjectMChannels) {
pub fn pcm_add_float(&self, samples: &[f32], channels: ProjectMChannels) {
if let Ok(instance) = self.instance.try_borrow() {
Projectm::pcm_add_float(*instance, samples, channels);
} else {
panic!("Failed to borrow instance");
}
}

pub fn pcm_add_int16(&self, samples: Vec<i16>, channels: ProjectMChannels) {
pub fn pcm_add_int16(&self, samples: &[i16], channels: ProjectMChannels) {
if let Ok(instance) = self.instance.try_borrow() {
Projectm::pcm_add_int16(*instance, samples, channels);
} else {
panic!("Failed to borrow instance");
}
}

pub fn pcm_add_uint8(&self, samples: Vec<u8>, channels: ProjectMChannels) {
pub fn pcm_add_uint8(&self, samples: &[u8], channels: ProjectMChannels) {
if let Ok(instance) = self.instance.try_borrow() {
Projectm::pcm_add_uint8(*instance, samples, channels);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod playlist {
#[test]
fn playlist() {
let projectm = ProjectM::create();
let playlist = Playlist::create(projectm);
let playlist = Playlist::create(&projectm);
assert_eq!(playlist.is_empty(), true);

// add ../presets to playlist
Expand Down
Loading