Open Wladimir25 opened 4 months ago
@Wladimir25 First, thanks for testing. It is not properly documented yet, since I wasn't sure if it'd work at all. What you need is Sampler.setCurrentFolder(0); it would set current sample set to the first found directory, as index in brackets is zero-based. Also a couple of methods available to increment/decrement current dir: Sampler.setNextFolder(), Sampler.setPrevFolder(), so you can bind them to some buttons or whatever. Later I modify the init() so that only folders with wav files would count. About the SD cards. I don't have many of them to compare. But I think mine are quite old also. General recomendations: format before use. Prepare your samples on your PC in advance and write them to SD in one take. If you need to modify samples some way, do it on PC, format card and write them again. This inconvenience is the price for not having fragmentation, and accordingly having no additional speed issues. This concerns only the wav files, so .ini and other files you can freely modify right on the card.
Hello, Thank you, got 2 buttons (inc/dec) working with the Lib 'Button2'. Regarding the performance of my sd card I made a test with sustain=on and got 15 voices, nice. I have seen that you have developed the code further (also with the possibilty for buttons), I will test it shortly. I'm very excited about the possibility of the ADSR.
Regards, Andreas
I forgot to mention possible wiring issues, as I mostly use modded LOLIN S3 Pro with the on-board micro-sd slot. The wires should be as short as possible, and of equal lengths. Also they say that external 10kOhm pull-ups are needed, but my boards work quite well with internal ones.
Hi,
I use these with short and equal wire connections on a breadboard:
Yes, with 10k pull-ups.
Your new code with the button is working well, no problems until now, thanks.
I would like to change the ADSR and Reverb via Midi CC...
Regards,
Andreas
Very nice SD slot, I couldn't find such one when I started this project.
I would like to change the ADSR and Reverb via Midi CC...
Reverb object is declared globally, so it's not a problem. I'll add support for reverb time and level via midi cc87 and cc88, as already stated in midi_config.h (or if you in a hurry, you're welcome to implement it yourself in any way you like). About ADSR, there's slightly more to think of. For now each single sample can hold ADSR parameters in sample_t struct, so it was intended to load these values on each note_on event along with other sample parameters. If you want to change these ADSR params in realtime without being overwritten on each note_on, there're changes to be made. These params should be deleted from sample_t, and declared within Sampler object, then it's better to pass their pointers to the created Voice objects, so that they were automatically propagated to all the voices when cc changes their values. It's not that hard actually, but I am struggling with clicks on polyphony overruns, and am a bit stuck, cause what I though would help -- helps not.
Hi, I'm back and tested your current code, works fine. Would you please give me an example for a system.ini for a string sound with x sec release? Is the 'range' part already working? Thank you very much Andreas
Hi and thanks or testing! [range] section should work, but for the time being there's no way to set the root note and to propagate the same sample with different speeds, using the [range]. The workaround for now is to name your files according to the root note and velocity of a sample. Name should include note name and octave (i.e. F#3), plus velocity layer (ie "forte"), so the filename can be named as "Strings_f#3_forte.wav". Then the filename template will look as following:
[filename]
Strings_<NAME><OCTAVE>_<VELO>
; And also we must include velocity variants
veloVariants = piano,forte
Global [envelope] section is the only way to set envelope params yet
[envelope]
default = true
; times in seconds
attackTime = 0.0
decayTime = 0.05
releaseTime = 12.0
; sustain level 0.0 - 1.0
sustainLevel = 1.0
Feel free to ask further
The uploaded version has a bit of midi CC's for ADSR and Reverb control
Hi, I'm testing your current code, compiled without problems. Thank you for the new code. One question regarding ADSR: I play a single note with a 50% Release and while the note fades out I reduce the Release to 0%. If I play the same note again, the note ends immediately. If I play another note this one ends immediately and the previously pressed note fades out (with Release 50%). Do I have a mistake in thinking? The project is great please continue developing! Thank you
Hi, there seems to be no mistake in what you've just described. Actually it's possible to change the parameters of a currently running adsr, but I suppose there's a chance that it would produce some clicks , which I'm tired of :-/
Hi, I have a further question regarding the number of possible voices:
The data of my SD-CARD: CARD: BEGIN Name: SC32G Type: SDHC/SDXC Speed: 40 MHz Size: 30436MB Bus width: 4 _firstSector 8192 _fsType 12 _sectorsTotal 62325760 Partition size = 30208 MB
Reading MBR done _sectorsPerFat 15209 _bytesPerSector 512 _numFats 2 _reservedSectors 2350 _rootCluster 2 _firstDataSector 32768 _sectorsPerCluster 32 _bytesPerCluster 16384 Reading BPB done. Reading 8 MBytes Reading block size: 3584 Bytes Time spent: 1612 ms Read speed: 4.96 MB/s
I get 'Active voices 5 of 17', is that ok? Thank you
Active voices 5 of 17 means that momentary you have 5 sounding voices, and 17 voices were allocated (#define MAX_POLYPHONY 17 in sampler.h)
I understand, but I don't get more than 5 voices. If I press more than 6 keys it says 4 of 17...
Is it with the latest source code?
Yes, I tested also the previous version, many more voices (>10) are possible here. With the new version only 6 voices are possible.
Please, check the newly uploaded version
Nice, working! Thank you! I keep on testing.
Active voices 16 of 18, great!
if you are not suffering of clicks, you can change
#define SACRIFY_VOICES
to 1, so get 17 of 18 voices running.
All these parameters depends on the particular hardware and sample sets:
#define MAX_POLYPHONY 18
#define SACRIFY_VOICES 2
#define MAX_SAME_NOTES 2
#define MAX_VELOCITY_LAYERS 16
#define MAX_DISTANCE_STRETCH 2
so find the best combination that suits your needs.
Also I 'd like to ask what version of Arduino IDE do you use? I ask because sometimes I get different results in ver 2.x.x compared to 1.x.x Also ESP32 Arduino core 3.0.x seems to work OK at the first sight, but after some retries the compiler started complaining on non-existant Serial :-/ I don't quite get it, as the behavior is unpredictable to my mind. It should depend on the "USB CDC on boot" but on my system it's quite random.
Hi, I use Arduino 1.8.19 and ESP32 2.0.16 USB CDC on boot = Dis I had to change USBSerial to Serial in your code, only then to get debug messages. No klicks to hear with the actual config I will test the Sampler with other parameters and and let you know if I hear any noises
Please make with the actual version following test: Release to maximum (e.g. via midi controller) play 5 different notes on the keyboard and then play a different but always the same key for 3 or more times the release phase of the 5 notes disappears, do you have the same?
I'll check asap
I don't have either IDE or s3 board by me, so "blindly" updated the logics. Please, check, if it compiles and if it fixes the issue. Also, Serial / USBSerial makes me sick... What board do you select in IDE? There should be working ``#if !ARDUINO_USB_CDC_ON_BOOT``` but I couldn't make a use of it yet
Very good, even when "blind" Only a ';' after float score was missing This problem is solved, but I found a probably new one... Release to maximum (e.g. via midi controller) You play e.g. 10 notes, one key after the other, all notes release fine but when you turn the release to zero while the played notes finish their release-time some notes are finished immediately and some fade out as if nothing had been done. I can't say which notes these are that didn't notice the release change.
Interesting: I play single notes Some notes are affected by the change to release=0 and some not. Gis, A, Ais, B seen to been affected and stop immediately, the others not. could this be due to the sampler.ini?
Hmm that's strange. On the 'release time' CC event the new values are loaded into the sampler mapping table and into each voice's adsr generator. They are not updated on note start, or somewhere else. I don't get it yet
Take your time
may this be the case that some notes are marked in the ini file as not receiving the note-off event?
My ini:
[sampleset] title = MegaWMM1 ; type=percussive/melodic type=melodic ; Are all the samples of equal loudness? If true then we apply amplification according to the midi note velocity. normalized=true ; Are the samples already amp-enveloped? enveloped=true
[filename]
;
; these elements are case insensitive, heading and trailing spaces are trimmed.
template=
; we must provide these variants along with the template. The order is important: from the most quiet to the most loud, comma separated veloVariants = 1
[range] first = F#6 last = G8 noteoff = false
; instr=instrument_name(as in filename) ; noteoff=0/1 (0=ignore, 1=end note) ; speed=float_number(1.0 means unchanged (default), 1.2 means 20% faster which is higher pitch, 0.9 is 10% lower)
[envelope] default = true ; times in seconds attackTime = 0.0 decayTime = 0.05 releaseTime = 5.0
; sustain level 0.0 - 1.0 sustainLevel = 1.0
No idea yet, will check it later
The wavs in the folder: C1v1.wav C2v1.wav C3v1.wav C4v1.wav C5v1.wav C6v1.wav
btw, why do you want to change the release time that often? Maybe sustain CC will suit better your needs?
Please, check the new version, it introduces exclusive note groups (mostly for percussive grouping, like only one can sound at a time: open hat or closed hat). Also, there's another attempt to make the code universal about using Serial/USBSerial.
Please, try #define ADSR_LIVE_UPDATE in config.h (if you set this param, the notes being played will get the updates along with CC changes (may produce some hisses) otherwise only the new notes' ADSR will be changed)
Hi, Only a few minutes ago installed the new version.
For debugging I had to change SerialPort to Serial. I think ARDUINO_USB_CDC_ON_BOOT =EN doesn't work. Test the exclusive note groups later Thank you!
For debugging I had to change SerialPort to Serial. I think ARDUINO_USB_CDC_ON_BOOT =EN doesn't work.
That is strange cause in misc.h SerialPort becomes either Serial or USBSerial. Can you debug which branch is active for you?
#if ARDUINO_USB_CDC_ON_BOOT //Serial used for USB CDC
HWCDC &SerialPort = Serial;
#else
HWCDC &SerialPort = USBSerial;
#endif
So either it says Serial was not defined
or USBSerial was not defined
Also, what board do you select?
If I use SerialPort: ARDUINO_USB_CDC_ON_BOOT = DIS: No debug information ARDUINO_USB_CDC_ON_BOOT = EN: No debug information If I use Serial.print and Serial.begin: Debug information available Arduino 1.8.19, ESP2.0.16, Board: ESP32S3 Dev Module Hardware: LOLIN S3 V1.0.0
If I use SerialPort: ARDUINO_USB_CDC_ON_BOOT = DIS: No debug information ARDUINO_USB_CDC_ON_BOOT = EN: No debug information
Do I get it right that you mean tools menu settings in IDE? And in both cases it will compile with no error?
Yes, tools menu in Arduino IDE. Yes, in both cases with no error.
With yous support I got some samples running with different parameters in the sampler.ini, sound good, thanks. Question: Are the parmeters in sampler.ini called: attack_time = 0.0 decay_time = 0.0 release_time = 2.0 sustain_level = 1.0 or attackTime = 0.0 decayTime = 0.0 releaseTime = 2.0 sustainLevel = 1.0 ?
I made syntax loose, so both styles (attack_time, attackTime) are valid. Even more, it's case insensitive.
Got a lot of samples working fine. Do you see a chance for start/loop/end points?
Yes, there's such possibility, but looping requires additional caching, and as we can't predict whether or not the player person keep it looping or release the key, we don't know in advance which part of the wave data we should pre-cache. For the current polyphony and caching settings I've already reached the limit. Concluding, I know how to implement looping of the whole file with quite no losses, but looping of a region seems to be a serious compromise in terms of polyphony (going to be about 1/3 less). BTW if you are going to use samples with loop regions, they are usually quite compact. Can you estimate the size of such sample set? If it's under 4mb or even 8mb, there's a chance that some other DIY sampler can handle it (I don't know if you are aware of Michael Licence's projects).
That sounds absolutely logical and understandable, thank you for your detailed explanation. I know Marcel's projects, also very interesting, but your project is the only DIY project I know that reads directly from the SD card. Are these boards known to you? https://www.sparkfun.com/products/20636 https://www.sparkfun.com/products/13660
I haven't had these boards in my hands, though I have seen a video demonstrating a DIY sampler based on one of these boards. Also I remember an ESP32 sampler based on WVR library and a custom PCB with a soldered memory chip. Though I managed to run it with a microSD. It has a lot of features and online editing, but it uses custom filesystem, and only supports uploading samples via WiFi web-server running on the ESP32.
Hello,
Thanks for sharing the great code. I installed it and it works fine. I couldn't reach the number of voices, I think it's because of my old and slow SD card. I have 2 directories with samples, how do I switch between them? The samples are currently being played in the second directory.
Thanks for further developing the code Andreas