Old 04-17-2018, 09:36 AM   #1
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
Default Sample-based synth - is it possible/wise?

If I wanted to implement a synth that loaded its samples from WAV files when it needed to (instead of holding them all in memory at once), what would be the best way to do that? Has anyone implemented this?

As far as I understand it: the file_open() function returns a handle, and if the file is a WAV then file_var() or file_mem(). I can hopefully keep the handle, reading out samples when I need them until the note is finished. I don't see a way to seek within a file, but I think I can work around that.

Is this an unwise idea?

Last edited by geraintluff; 04-17-2018 at 09:49 AM.
geraintluff is offline   Reply With Quote
Old 04-17-2018, 10:34 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

You will go insane trying to implement something like that with JesuSonic.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 04-17-2018, 11:35 AM   #3
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,891
Default

Quote:
Originally Posted by geraintluff View Post
Is this an unwise idea?
Haha, that's a terrible idea but I'm sure you'll have fun trying to make it work!
IXix is offline   Reply With Quote
Old 04-17-2018, 04:21 PM   #4
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
Default

Well, the actual idea is not too hard - here's a proof-of-concept demo that I just knocked together. That doesn't cache the files at all (so it will get multiple handles for the same file if multiple notes are using the sample), and it uses simple linear interpolation, but it still works.

I was more wondering what kind of performance issues or whatever I might run into, or if there are technical limitations to this kind of approach that are going to scupper me months later.

For example, many sample-based synths that stream from disk will buffer ahead, but that's something you can only do if you have threads, so not being able to do that might have latency implications. Does using file_open() with a number (instead of a string) keep some kind of reference to the file in the file system, or is resolving the filename every time the file is opened?

Last edited by geraintluff; 04-17-2018 at 05:06 PM.
geraintluff is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.