Code Monkey home page Code Monkey logo

deno_audio's Introduction


deno_audio logo

deno_audio

Audio playback library for Deno.

stars issues deno version

Example

import { play } from "https://deno.land/x/[email protected]/mod.ts";

// supports mp3, wav, vorbis, flac
await play("music.mp3");

Building from source

Prerequisites

Building

$ deno_bindgen --release

Example

$ deno run --unstable -A example.ts

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Copyright

Logo by @carazmatic at picsart.com (cute, isn't it?)

deno_audio is licensed under the MIT license. Please see the LICENSE file.

deno_audio's People

Contributors

littledivy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deno_audio's Issues

Stop sound

It would be really useful for me if I could stop a sound again after starting it. I am using this library to play music in the background, but between scenes the music needs to be changed to something else and that's impossible right now if I can't stop the one that's currently playing... Would there be a way to do this?

[FEATURE REQUEST] Support for Apple Silicon (M1)

When we try to run the module in a macOS running in arm64 architecture:

deno run --allow-all --unstable index.ts
error: Uncaught (in promise) Error: Could not open library: Could not open library: dlopen(~/Library/Caches/deno/plug/https/github.com/f53f000ac09e54195c49f3ca7d32b3dcff62ed2a62e213f36a5a4e02875d7d7c.dylib, 0x0005): tried: '~/Library/Caches/deno/plug/https/github.com/f53f000ac09e54195c49f3ca7d32b3dcff62ed2a62e213f36a5a4e02875d7d7c.dylib'
(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
  return Deno.dlopen(file, symbols);
              ^
    at new DynamicLibrary (deno:ext/ffi/00_ffi.js:274:39)
    at Object.dlopen (deno:ext/ffi/00_ffi.js:368:12)
    at prepare (https://deno.land/x/[email protected]/plug.ts:106:15)
    at async https://deno.land/x/[email protected]/bindings/bindings.ts:28:14

Notice the error part: mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))

`play()` doesn't work with latest deno `1.26.2` on Windows

I tried to use your module with the latest deno version and stumbled upon the following error:

error: Uncaught (in promise) TypeError: Invalid FFI pointer type, expected null, integer or BigInt
await play("music.mp3");

This seems to be related to some type changes.
I could fix it by changing pointer to buffer here:

play: { parameters: ["pointer", "usize"], result: "void", nonblocking: true },

undefined symbol: init_deno_bindgen

Trying my luck with this package...
I've installed the prerequisites. Then:

▶ deno_bindgen --release           
   Compiling proc-macro2 v1.0.76
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.152
   Compiling serde v1.0.195
   Compiling memchr v2.7.1
   Compiling serde_json v1.0.111
   Compiling pkg-config v0.3.28
   Compiling thiserror v1.0.56
   Compiling regex-syntax v0.8.2
   Compiling quote v1.0.35
   Compiling alsa-sys v0.3.1
   Compiling syn v2.0.48
   Compiling aho-corasick v1.1.2
   Compiling nix v0.15.0
   Compiling cfg-if v0.1.10
   Compiling bitflags v1.3.2
   Compiling void v1.0.2
   Compiling syn v1.0.109
   Compiling cc v1.0.83
   Compiling regex-automata v0.4.3
   Compiling minimp3-sys v0.3.2
   Compiling lazy_static v1.4.0
   Compiling cpal v0.12.1
   Compiling ryu v1.0.16
   Compiling tinyvec_macros v0.1.1
   Compiling byteorder v1.5.0
   Compiling itoa v1.0.10
   Compiling tinyvec v1.6.0
   Compiling ogg v0.8.0
   Compiling regex v1.10.2
   Compiling alsa v0.4.3
   Compiling Inflector v0.11.4
   Compiling slice-deque v0.3.0
   Compiling lewton v0.10.2
   Compiling hound v3.5.1
   Compiling claxon v0.4.3
   Compiling serde_derive v1.0.195
   Compiling thiserror-impl v1.0.56
   Compiling minimp3 v0.5.1
   Compiling rodio v0.12.0
   Compiling deno_bindgen_macro v0.5.1
   Compiling deno_bindgen v0.5.1
   Compiling deno_audio v0.1.0 (/home/me/deno_audio-main)
    Finished release [optimized] target(s) in 10.75s
Initializing deno_audio
Error: Custom { kind: Other, error: "failed to load library: Could not obtain symbol from the library: /home/me/deno_audio-main/target/release/libdeno_audio.so: undefined symbol: init_deno_bindgen" }

Anything I might have forgotten?
Unfortunately searching init_deno_bindgen on google returns zero result... Where does this come from?

Using the latest version (0.2.0) of deno_audio, with a freshly installed rust, latest deno_bindgen_cli 0.1.0, on Ubuntu 23.04.

[feature request]: volume options and support for rodio spatial

Examples

import { play, playSpatial } from '...';
await play('sound.mp3', { volume: 0.3 /* 30% volume */ });
await playSpatial('otherSound.mp3', {
  soundPos: [1, 2, 3], // position of sound
  pos: [1, 1, 1] // position of the user listening to the sound
})

Question

Hey,

is there any way to modify the lib to play buffers instead of files?

mod files

I am thinking about using this lib (which looks rad, by the way) with mod-player so I can have both efficient & small mods for music, and audio-files for sound effects (for like a game engine). Is there any interest in a PR for mod support? I could also see wrapping it with a separate deno module, but I feel like there might be some nice overlap if it were combined.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.