Skip to content

Commit

Permalink
support mono audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikai-Liao committed Nov 3, 2024
1 parent 88a3f54 commit a67dd3d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
30 changes: 28 additions & 2 deletions py_src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>
#include <nanobind/stl/filesystem.h>
#include "prestosynth/wav.h"
#include "symusic.h"
#include "py_utils.h"
#include "MetaMacro.h"
Expand Down Expand Up @@ -58,9 +59,34 @@ nb::module_& bind_synthesizer(nb::module_& m) {
);


// m.def(
// "dump_wav",
// &psynth::write_audio,
// nb::arg("path"),
// nb::arg("data"),
// nb::arg("sample_rate"),
// nb::arg("use_int16") = true
// );


m.def(
"dump_wav",
&psynth::write_audio,
"dump_wav",[](
const std::string& path,
const nb::ndarray<f32, nb::shape<-1, -1>, nb::device::cpu>& data,
const i32 sample_rate,
const bool use_int16
){
// show the shape of the data
std::cout << "data shape: " << data.shape(0) << " " << data.shape(1) << std::endl;
psynth::WAVE_write(
path,
data.shape(0),
data.shape(1),
sample_rate,
data.data(),
use_int16
);
},
nb::arg("path"),
nb::arg("data"),
nb::arg("sample_rate"),
Expand Down
4 changes: 0 additions & 4 deletions py_src/py_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "nanobind/operators.h"
#include <nanobind/ndarray.h>





namespace pyutils {

using namespace symusic;
Expand Down

0 comments on commit a67dd3d

Please sign in to comment.