Skip to content

Commit

Permalink
Allow for WASI publishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
twitchax committed Jun 17, 2023
1 parent e4698f2 commit 04c3464
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ $ wasm-pack publish
## Publish to wasmer

```bash
$ cargo wasix build --release --features ml_infer
$ cargo wasi build --release --no-default-features --features cli --features ml_infer --features analyze_file
$ cargo wasix publish
```
2 changes: 1 addition & 1 deletion src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ fn start(args: Args) -> Void {
// Show the results.
show_notes_and_chords(&notes)?;
}
None => {
_ => {
return Err(anyhow::Error::msg("Invalid inference command."));
}
},
Expand Down
4 changes: 4 additions & 0 deletions src/core/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use std::time::Duration;

#[cfg(feature = "audio")]
use rodio::{OutputStream, OutputStreamHandle, Sink};

/// Global result type.
Expand Down Expand Up @@ -50,12 +51,14 @@ pub trait Parsable {
}

/// A struct for holding the types for a [`Playable`].
#[cfg(feature = "audio")]
pub struct PlaybackHandle {
_stream: OutputStream,
_stream_handle: OutputStreamHandle,
_sinks: Vec<Sink>,
}

#[cfg(feature = "audio")]
impl PlaybackHandle {
/// Creates a new [`PlayableResult`].
pub fn new(stream: OutputStream, stream_handle: OutputStreamHandle, sinks: Vec<Sink>) -> Self {
Expand All @@ -81,6 +84,7 @@ impl PlaybackHandle {
/// );
/// std::thread::sleep(Duration::from_secs(1));
/// ```
#[cfg(feature = "audio")]
pub trait Playable {
/// Plays the [`Playable`].
#[must_use = "Dropping the PlayableResult will stop the playback."]
Expand Down
5 changes: 3 additions & 2 deletions src/ml/base/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::path::Path;

use crate::{
analyze::{
base::{get_frequency_space, get_smoothed_frequency_space},
mic::get_audio_data_from_microphone,
base::{get_frequency_space, get_smoothed_frequency_space}
},
core::{
base::{Parsable, Void},
Expand All @@ -14,6 +13,8 @@ use crate::{
ml::base::{KordItem, FREQUENCY_SPACE_SIZE},
};

use crate::analyze::mic::get_audio_data_from_microphone;

use super::helpers::save_kord_item;

/// Gather a sample from the microphone and save it to disk.
Expand Down
1 change: 1 addition & 0 deletions src/ml/base/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Base types for machine learning.

pub mod data;
#[cfg(feature = "analyze_mic")]
pub mod gather;
pub mod helpers;
pub mod mlp;
Expand Down
25 changes: 25 additions & 0 deletions wasmer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = 'twitchax/kord'
version = '0.6.1'
description = 'A tool to easily explore music theory principles.'
license = 'MIT'
readme = 'README.md'
repository = 'https://github.com/twitchax/kord'
homepage = 'https://github.com/twitchax/kord'

# See more keys and definitions at https://docs.wasmer.io/ecosystem/wapm/manifest

[dependencies]

[[module]]
name = 'kord'
source = 'target/wasm32-wasi/release/kord.wasm'
abi = 'wasi'

[module.interfaces]
wasi = '0.1.0-unstable'

[[command]]
name = 'kord'
module = 'kord'
runner = "https://webc.org/runner/wasi"

0 comments on commit 04c3464

Please sign in to comment.