Skip to content

Commit

Permalink
Allow passing PCM data as slices instead of Vec (#18)
Browse files Browse the repository at this point in the history
* Allow passing PCM data as slices instead of Vec

* version bump
  • Loading branch information
revmischa authored Nov 29, 2024
1 parent 81bc141 commit 7fb2aea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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 <anomievision@gmail.com.com>", "Mischa Spiegelmock <me@mish.dev>"]
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

0 comments on commit 7fb2aea

Please sign in to comment.