Author |
Message |
Grumble
Joined: Nov 23, 2015 Posts: 1301 Location: Netherlands
Audio files: 30
|
Posted: Thu Dec 06, 2018 2:23 pm Post subject:
|
|
|
I learned machine code on a self made "machine" built around the HD64180
I even had it sampling audio under dma, a video interface, a soundboard with a AY38910 all written in machine code.
Then I got the Junior computer around the 6502 and then a REAL computer: the Acorn Atom (also 6502 based)
Yup, same age as you _________________ my synth |
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
Posted: Thu Dec 06, 2018 2:26 pm Post subject:
|
|
|
As an addendum - There is a way to possibly speed up the low pass IIR filter which also eliminates the need for the b1 variable:
The formula can be rewritten algebraically as:
Code: |
z = z + a0 * ( in - z )
|
_________________ FPGA, dsPIC and Fatman Synth Stuff
Time flies like a banana. Fruit flies when you're having fun. BTW, Do these genes make my ass look fat? corruptio optimi pessima
|
|
Back to top
|
|
|
JLS
Joined: Nov 05, 2005 Posts: 499 Location: Czech
Audio files: 30
G2 patch files: 316
|
|
Back to top
|
|
|
MapacheRaper
Joined: Feb 15, 2018 Posts: 166 Location: Spain
|
Posted: Sat Dec 29, 2018 4:45 pm Post subject:
|
|
|
Cool! I´ll be testing it in no time. Thanks!! |
|
Back to top
|
|
|
JLS
Joined: Nov 05, 2005 Posts: 499 Location: Czech
Audio files: 30
G2 patch files: 316
|
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
Posted: Sun Dec 30, 2018 8:50 am Post subject:
|
|
|
JLS wrote: | Floating point version Arduino Karplus-Strong.
- better sound
- better lowpass filtering
- but needs more memory and cpu resources |
This is why I use STM32 ARMs. The better ones have single cycle float multiply and float add (from a hardware FPU), they have a lot more SRAM and they are a lot faster. There are also several DSP instructions including square root and MAC. Still can use C, but the environment is different if you move away from the arduino compatible chips. If gcc is given the correct optimization strings, it will use DSP instructions where possible (which speeds things up). STM32H7 for example runs at 400 MHz and has 1 megabyte of internal SRAM (though not all of it is contiguous, there is a 512 kbyte contiguous piece).
I use a completely free set of tools, though there's some initial angst in setting it all up. gcc needs to have stuff added so that it can cross compile. There are also GUI based environments (like Eclipse), but I found those to be confusing, tedious and non-intuitive. My typical work cycle is
1) edit source with my favorite text editor
2) issue a make command to compile the code
3) send the binary to the ARM and test.
4) repeat as necessary.
The arduino platform is great for learning about microcontrollers, but while it does things that might make coding easier - they also make the code slower. Those constrictions go away when you leave the arduino world and once you learn how to do things the non-arduino way, you'll be able to use any processor out there not just those in the arduino developer world. _________________ FPGA, dsPIC and Fatman Synth Stuff
Time flies like a banana. Fruit flies when you're having fun. BTW, Do these genes make my ass look fat? corruptio optimi pessima
|
|
Back to top
|
|
|
MapacheRaper
Joined: Feb 15, 2018 Posts: 166 Location: Spain
|
Posted: Mon Dec 31, 2018 7:35 am Post subject:
|
|
|
That floating point version seems really cool JLS. Im diying to test it. Thanks for sharing!
@Jovian, yepp, after some weeks playing with the arduino I see you are totally right. It is more intended for gating/triggering, sequencing, etc, but for DSP it needs way more meat (even if you can do some cool tricks too, even complete oscillators)
Jovian, has you taken a peek at the ESP8266 and ESP32 chips?. It packs a lot of power and bang for the buck. Definitively I think we will see some next gen O_C and mutable type of things coming from this chips |
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
Posted: Mon Dec 31, 2018 12:45 pm Post subject:
|
|
|
I had not seen the ESP chips. I don't need the wifi tho. I've had really good experience with the STM32 stuff, so I'll stick with that. Dual core is nice, but troublesome to get 2 cores cooperating usefully (parallel processing). For synth projects, a fast single core CPU is far less bother IMO. I've written multithreaded polysynths for a raspberry pi3 and that code still has issues regarding coordination of threads and memory sharing. _________________ FPGA, dsPIC and Fatman Synth Stuff
Time flies like a banana. Fruit flies when you're having fun. BTW, Do these genes make my ass look fat? corruptio optimi pessima
|
|
Back to top
|
|
|
MapacheRaper
Joined: Feb 15, 2018 Posts: 166 Location: Spain
|
Posted: Mon Dec 31, 2018 1:08 pm Post subject:
|
|
|
I have never done multithread, but I have meditate about it and it looks like a pain in the ass, yes. But we like it or not it´s what the future brings. It seems like 3-4GHz is the max speed that silicon does and the current state of the art chips are growing in parallel giving more and more multitreads.
So I guess somehow code will adapt to that, maybe facilitating or even completely inmaskaring in in the framework (so the framework do all the heavylifting transparently for the coder)
Regarding ESP, I see it with a lot of potential. Imagine the Ornament and Crime. Probable the more succesful open source module in existence. All people using it. A ESP version could use the wifi to connect with the smartphone/computer, so suddenly you have snapshots of the patches (infinite patches memory) plus you can control the secuencers and whatnot from the phone. And run different algoridms in every channel, something that most users ask but is quite difficult to implement in the module now.
And all this in a chip that costs 2-3USD instead of the 20-30 of the teensy.
Interesting times, for sure. I guess we will have a new wave of completely new functions in modules, no seen yet, in no time, as people start to hack with the ESP and find his treasoures
With that said, I have some SMT32 arriving in the next days too. Yumm |
|
Back to top
|
|
|
remedios_dream
Joined: Apr 26, 2021 Posts: 3 Location: eternity
|
Posted: Mon Apr 26, 2021 3:41 pm Post subject:
|
|
|
@JLS
I see the topic is quite old I would like to ask for your help.
If I understand code right: assuming the sampling frequency is 22050 and our delay size is 256 we have one of 255 frequencies available, right?
Where:
freq = sample_rate / bound
where max size of bound is 255.
Is there any way to get more frequencies? The simplest one is to make delay array bigger but arduino will be out of ram then.
Maybe there's another karplus-strong implementation that do not require creating large data array?
Last one could you please explain what `accum` is? |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24138 Location: The Netherlands, Enschede
Audio files: 279
G2 patch files: 320
|
Posted: Mon Apr 26, 2021 8:43 pm Post subject:
|
|
|
remedios_dream wrote: | Is there any way to get more frequencies? |
Yes there is, you can interpolate between the possible integer taps to make fractional taps.
In that way only your lowest possible frequency will be determined by the delay length (and the sample rate).
Basically what you will do then is to calculate the number "delay cells" that you would need for some frequency. This will not be an integer in general, but you can take a bit of the tap at the integer value and a bit of the next step. Getting more of the integer tap when closer to that or more of the next when closer to that.
So, the amounts to take from each steps will vary as to which one you are nearer to.
The interpolation algorithm used for this in it simplest form is linear, but there are other interpolation algorithms too.
Linear meaning that when you are halfway you use half of both step outputs summed, or when it is something.25 .. use 3/4 of the first and 1/4 of the next.
I know of two algorithms, the linear one I mentioned, and ther also is an allpass interpolation algorithm. The 2nd one giving better results, but behaving a bit odd for sliding notes, and the first one doing better for sliding notes but having some amplitude differences between notes. There may be more ideas about this that I have no knowledge of
Another thing you could use, in order to use very short delays, would be to use a readout pointer on the delay line that is not fixed but one that moves .. .you could move it slower than the sample rate to get lower frequencies - I've never tried this myself, but I know JovianPyx has been doing something along these lines. Alas, he never disclosed the details and he is no longer amongst us earthlings to tell.
Anyway, in that way you could even decouple the lowest possible note from the delay length used (by moving the readout ponter on the delay line slower than the sample rate).
Sooo .. this is about what I know about the KS thing maybe a bit of googling from this info will help you to move forward?
Aand .. also to the forum remedios_dream. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
remedios_dream
Joined: Apr 26, 2021 Posts: 3 Location: eternity
|
Posted: Tue Apr 27, 2021 1:43 pm Post subject:
|
|
|
@Blue Hell
Thank you for your answer,
You're right I totally forgot about interpolation here, also moving pointer is cool idea. I've used it several times in few wavetable kinda synthesis projects.
My main platform is stm32, unfortunately covid hits badly and those chips getting more and more expensive. I'm considering a step back, for a reasonable price.
Now I see that there's one thing which I have to learn.. How to imitate floats in weaker mcus.
There's a lot of binary shifts in code and I assume that's because we try to imitate floating point, right?
Do you recommend any resources on how to start dsp with such 8 bit micros? |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24138 Location: The Netherlands, Enschede
Audio files: 279
G2 patch files: 320
|
Posted: Tue Apr 27, 2021 2:03 pm Post subject:
|
|
|
For non floating point .. have a look at fixed point math .. you can probably find some C macros doing the hard work for you .. although it is not really that hard, it involves some shifting ...
Only thing is with 16 bit math you need to be careful not to under- or over-flow things .. which may need some occasional rescaling (more shifts!), or using 32 bit intermediate values here and there.
And 32 bit math everywhere might be too expensive CPU wise ... and 8 bit math .. just too poor.
The shifts of course are just cheap multiplication and division (by factors of two). _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
danielfiction
Joined: Jul 15, 2009 Posts: 9 Location: nyc
|
Posted: Sat May 01, 2021 2:48 pm Post subject:
Subject description: mysterious |
|
|
JLS wrote: | Update Arduino Karplus-Strong.
- better triggering
- better timers (PWM PIN 11)
Example Simple Karplus-Strong and duophonic Karplus-Automata cellular automata sequencer |
Hello!
I've been following this thread with great interest. But try as I might, these code examples produce no sound. I'm running an Arduino Uno. My wiring works fine—I've checked it with other pin9 Direct Digital Synthesis libraries such as Mozi, and my potentiometers work correctly.
is there something i'm missing? a library installed? wrong board?
best,
daniel |
|
Back to top
|
|
|
danielfiction
Joined: Jul 15, 2009 Posts: 9 Location: nyc
|
Posted: Sat May 01, 2021 3:15 pm Post subject:
Subject description: mysterious |
|
|
Oh, i figured it out—I couldn't just change PWM Pin to 9, I had to manually wire it to 11, 3, or 9 according to the sketch.
would anyone mind telling me why that is? I usually make these changes in code without breaking functionality at all!
[quote="danielfiction"] JLS wrote: | Update Arduino Karplus-Strong.
Hello!
I've been following this thread with great interest. But try as I might, these code examples produce no sound. I'm running an Arduino Uno. My wiring works fine—I've checked it with other pin9 Direct Digital Synthesis libraries such as Mozi, and my potentiometers work correctly.
is there something i'm missing? a library installed? wrong board?
best,
daniel |
|
|
Back to top
|
|
|
herd
Joined: Sep 18, 2021 Posts: 4 Location: herd
|
Posted: Sun Sep 19, 2021 6:00 am Post subject:
|
|
|
necro posting, just wastin' time here,
never understood why communities were so insular.
THE reference for karplus-strong is ccrma at stanford. i kind of feel like julius o. smith III is the qi jiguang of our time, he died for your syns, notate everything, give it to the people.
even if you just stare at the pictures, julius' pages will tell you about most things you want to be aware of, to some functional level.
(one of the other prehistoric university hosted dsp pages has just disappeared, god help us when ccrma goes down)
i've only messed with k-s in a purely dsp environ. linear interpolation is kind of like a free lowpass you don't want (the algorithm is a 6dB lowpass). 2nd order hermite (musicdsp.org or at least was) at 44.1k will give you arbitrary decay lengths that are practically undamped for perhaps a minute, much better than cubic.
you want an allpass (3rd or 4th order) or more in your delay line to add "stiffness"/nice metally tones. you'll want to redact the delay line length for this.
if you get an environ where you can implement it, coupling two lines orthogonally ("vertical and horizontal vibrations") with different damping settings allows you to shape a more realistic amplitude contour. using a similar scheme with different lengths allows you to play touch harmonics.
injecting a white noise impulse is traditional but i prefer envelopes or shaped impulses (or mass-springs). you can also use a constant white noise (filtered?) for bowing effects or "fun wind instruments".
qi jiguang and julius o. smith III are your best friends ever. remember where they are. |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24138 Location: The Netherlands, Enschede
Audio files: 279
G2 patch files: 320
|
Posted: Mon Sep 20, 2021 4:50 am Post subject:
|
|
|
Ah, thanks for your comments herd - they might get me to do things again _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
elektromeister
Joined: Feb 18, 2013 Posts: 32 Location: Freiburg
|
Posted: Tue Oct 17, 2023 9:11 am Post subject:
|
|
|
I once programmed such a KS-Algo on my DSP - using this idea of multiple feed backs:
http://www.96khz.org/htm/waveguide3stage2.htm
The author states it was fine for guitars because it also creates slightly detuned third harmonics which comes more close to the real guitar.
We observe the same behavior in metal material which is bended and under torsion. Real waves differ from the mathematical ideal. _________________ music is the key |
|
Back to top
|
|
|
danielfiction
Joined: Jul 15, 2009 Posts: 9 Location: nyc
|
Posted: Sun Nov 05, 2023 9:03 pm Post subject:
Solar Karplus Strong Success Subject description: making cool sounds with cheap chips |
|
|
|
|
Back to top
|
|
|
danielfiction
Joined: Jul 15, 2009 Posts: 9 Location: nyc
|
Posted: Sun Nov 05, 2023 9:07 pm Post subject:
|
|
|
JLS wrote: | One my simplest arduino karplus "synth" |
hi all!
This is a cool old thread with lots of creative potential.
I wanted to get some Karplus Strong synth sounds running on an atmega328. I designed a board that implements the atmel chip with an onboard amplifier, a solar panel, and a few analog inputs (voltage divider straight off the solar panel, also a thermistor).
The code I've been working with really is optimized for "aleatoric" operation, ie, just kind of sitting back and letting the music change around you. (i've made about 25 of these solar powered autonomous instruments, but that's another story. anyway, it works, and this thread was really helpful as I was getting it off the ground.
I made a few different boards for it back in 2021 and I'm just dusting it off to make a new run of PCBs. excited to add some controls to it, and some depth to the code!
@JLS, your code has been really helpful in getting my circuit working. I thank you so much for sharing it!
https://www.instagram.com/p/CSNFi6AlKqx/
here's a video of the solar sounder running karplus strong. |
|
Back to top
|
|
|
mosc
Site Admin
Joined: Jan 31, 2003 Posts: 18207 Location: Durham, NC
Audio files: 217
G2 patch files: 60
|
Posted: Thu Nov 09, 2023 1:37 pm Post subject:
|
|
|
I love that video. A beautiful gizmo that Stan Lunetta would be proud of. _________________ --Howard
my music and other stuff |
|
Back to top
|
|
|
rolfs
Joined: Mar 20, 2014 Posts: 8 Location: germany
|
Posted: Tue May 07, 2024 4:49 am Post subject:
|
|
|
blue hell wrote: |
And 32 bit math everywhere might be too expensive CPU wise ... and 8 bit math .. just too poor. |
Reading this ... Question: Wasn't the K-P-Algorithm designed to save resources in the first place?
And wasn't the 8 bit a part of the sound shaping? Because of it's artifacts? |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24138 Location: The Netherlands, Enschede
Audio files: 279
G2 patch files: 320
|
Posted: Fri May 17, 2024 8:06 am Post subject:
|
|
|
rolfs wrote: | blue hell wrote: |
And 32 bit math everywhere might be too expensive CPU wise ... and 8 bit math .. just too poor. |
Reading this ... Question: Wasn't the K-P-Algorithm designed to save resources in the first place?
And wasn't the 8 bit a part of the sound shaping? Because of it's artifacts? |
Ah, I don't know, and could well be but I never heard that
[should experiment again .. some day ..] _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
|