Compare commits

...

5 commits

Author SHA1 Message Date
430677fc07 enhance embed custom plugin
- seek to 0 on setup
 - ignore and copy original bytes if we reached end of audio file
2019-10-22 19:16:09 -03:00
c8b5327634 libsndfile cant open mp3s 2019-10-22 19:09:05 -03:00
1c6ef1d4d5 Revert "use sf_open_fd"
This reverts commit 6e66850d90.
2019-10-22 19:08:38 -03:00
6e66850d90 use sf_open_fd 2019-10-22 18:57:36 -03:00
2d64eaa3ef add embed example script 2019-10-22 18:30:55 -03:00
4 changed files with 9 additions and 2 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
zig-cache/
*.mp3
*.wav

3
examples/embed.scri Normal file
View file

@ -0,0 +1,3 @@
load :0;
embed 3 1 ./file.wav;
quicksave;

View file

@ -164,6 +164,8 @@ pub const Embed = struct {
&in_fmt,
);
image.sseek(self.sndfile, 0);
self.buf = try self.allocator.alloc(f32, @intCast(usize, in_fmt.channels));
}
@ -173,7 +175,7 @@ pub const Embed = struct {
const read_bytes = c.sf_readf_float(self.sndfile, self.buf.ptr, 1);
if (read_bytes == 0) {
std.debug.warn("WARN! reached EOF for embed\n");
bufs.out[0] = bufs.in[0];
return;
}

View file

@ -65,7 +65,7 @@ pub fn swrite(file: *c.SNDFILE, buf: [*]f32, frames: i64) !void {
}
}
fn sseek(file: *c.SNDFILE, offset: usize) void {
pub fn sseek(file: *c.SNDFILE, offset: usize) void {
const offset_i64 = @intCast(i64, offset);
const frames = c.sf_seek(file, offset_i64, c.SEEK_SET);
const frames_current = c.sf_seek(file, 0, c.SEEK_CUR);