I discovered something interesting as I was tinkering with midi. It appears that midi does not understand the length of a sound utterance, only when it begins and ends. So the midi library that I use in python can read those events and I work backwards to obtain the length of the notes. My premise was that if the sample was fit within the boundries of the playback time, things like attack, sustain, and release envelopes would be unnecessary. And it appears that I am correct. In the cases where samples really don't sound good stretched 8x (like when they have a touch of vibrato), I'm thinking I could make a set of derivatives that crossfade long samples to make extended lengths.
I made a library called get_sample.py that loads a dictionary list combo containing information about the sounds such as the sample file, its offset and true sound length (there is usually emptiness before and after the sample plays). The offset keeps notes firing in the right time and the length is used to find the closest match for the sample. Although there are over 10k samples stretching the samples in ffmpeg led to many unpleasant artifacts even with the rubberband filter. I found however that the rubberband-cli utility has a different set of options and appears to be a different method as the quality is astoundingly better with it as compared to the ffmpeg filter. My get_sample library first finds the closest length of the native samples or sub pitch sample, and then it will run down a list to find the closest scaled version. I had to generate about 2 million derivative samples to get a decent number of lengths to use as ffmpeg can only cleanly scale by about 25% in either direction. Amazingly, rubberband-cli can stretch a sample 8x with little noticeable jitters or stretch problems. Rubberband-cli is even better than sox I found.
It was an iterative process, trying things that work and abandoning things that didn't. After converting my project to use rubberband-cli samples I rerendered my project collection and erased and replaced the old examples on YouTube. By saving those samples as mp3 files the collection comes in at about 50 GB. Since the files started as mp3, it didn't seem like expanding 2 million samples to 800 gb of wavs was worth the space on my drive. I think that is about right as some people using products like Hollywood eastwest opus complain that it can take more than a day to download and more than a day to unpack the samples (it uses almost a whole TB of ssd space). Memory consumption is moderate, but you'll need just a little more memory than a cheap laptop has (8 GB will get it done just fine). The biggest drawback could be that this is actually more of a renderer than what people imagine as a synth. The system cannot play the music in realtime, it has to process the sound in parallel batches using ffmpeg. Usually a song takes much less time to render than to listen to but if it is something like Bach, its going to take a heck of a long time to render a job.
Kind of to my dismay I have been beaten to the punch with similar solutions that came out around 2018 but didn't know because I wasn't in the market for something like this. My solution seems easier to get quick results but is limited to the collection of samples that I have. Many samples were incorrectly labeled for their pitch so I'm still picking them out now and then and putting them in a banned list. I still haven't quite figured out why I cannot realistically make groups of instruments play that sound like they were mic'ed on a stage like some other offerings I've seen. So string ensembles of 8 violins for me doesn't really sound a lot different than just one for the time being. But combining viola, violin, cello, and double-bass usually gets what I'm looking for anyway.
My whole project was made possible by the endless numbers of libraries for python that just seemed to be lying around waiting for someone like me to pick up and apply to such a project as this one.
I wish I could get in touch with the London Philharmonia orchestra seeing that I couldn't find anyone that did something with their massive sample donation. I thought they'd want to see what could be done with it. I'm currently unemployed and fear unemployable..