Building musical synthesizers and keyboards - Page 1
Forum section: electronics / projects

author: PauloConstantino
author_rank: Regular Contributor
timestamp: June 21, 2017, 05:42:45 am
content: Hi there,I've been VERY interested in building myself a synthesizer, sequencer + keyboard system!I was building some sound circuits for my homemade 8bit cpu, and I got pretty interested in electronic sound generation, and then I went into the magic of synths. oh man what was I missing !! They're the most amazing thing!So now I want to build one. I am very experienced with digital electronics but not much with analog, and I've been dwelving into analog these days more via textbooks to learn what I don't know.So what do you guys advise as a place to start? I'd like to build an analog synth, because a digital one would really be too easy. I don't want to use a microcontroller. I want to do it via discrete analog components, and discrete logic for control as needed.Do you guys know of a good book on designing synths? Maybe a website? Maybe some advice ?Thanks a lot!

author: Fungus
author_rank: Super Contributor
timestamp: June 21, 2017, 09:53:12 am
content: a) It's not easy! A lot of the circuits/modules are quite complex - everything has to be voltage controlled.b) Start with google:https://encrypted.google.com/search?q=building+analog+synthsc) Don't rule out microprocessors completely. They can save you a LOT of work for things like the keyboard input (which doesn't actually produce sound so a synth is still an analog synth even if the keyboard is digital). You can always remove them later if you're a purist.d) Starting with an Arduino andsimple function generator(or two) will let you get to work on the important units right away (ADSRs, LFOs, filters, etc.) and it will still be 'analog', technically speaking.

author: AndreasF
author_rank: Frequent Contributor
timestamp: June 21, 2017, 10:10:52 am
content: This might be helpful:http://www.sdiy.info/w/Schematics_and_manuals

author: Lee Leduc
author_rank: Regular Contributor
timestamp: June 21, 2017, 11:07:42 am
content: http://musicfromouterspace.com/SYNTH-DIY section

author: magetoo
author_rank: Frequent Contributor
timestamp: June 21, 2017, 12:16:07 pm
content: Quote from: PauloConstantino on June 21, 2017, 05:42:45 amToo easy? It's pretty complicated if you want to do it right and not just half-ass a DSP or micro implementation. Maybe I'm biased from having sketched out part of one in discrete logic...But you wanted pointers for analog:VideoAaron Lanterman's "Electronics for Music Synthesis" lecture videos; seeherefor links. Must see.BooksHal Chamberlin, "Musical Applications of Microprocessors" is recommended all the time. Out of print. No, it's not about digital synthesis.Barry Klein, "Electronic Music Circuits" is another that gets mentioned. I've seen a PDF of it somewhere.Thesynth-diy mailing listis where the serious builders go. Lots of information in the archives.Some other places worth mentioning:Muff Wiggler forum(mostly modulars and kit builders IIRC)DIY sectionof the Electro-music forumKen Stone / CGSSchmitzbitsYou'll come across OTAs a lot, so might as well check out this article, "Understanding and using OTA op-amp ICs" by Ray Marston; partone,two(PDF), and perhapsthisbit of "errata".That should get you started, I hope it's not too much!

author: Keicar
author_rank: Regular Contributor
timestamp: June 21, 2017, 12:30:45 pm
content: The difficulty to achieving pitch stability in VCOs is temperature compensation of the exponential converter - here's a paper I found on the subject:http://www.openmusiclabs.com/files/expotemp.pdf

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 21, 2017, 02:20:52 pm
content: If you can do digital you should use it, why logic control ?, because it is fun might be the reason for you, your circuit will be very big especially as first project.

author: diyaudio
author_rank: Frequent Contributor
timestamp: June 21, 2017, 04:31:20 pm
content: Quote from: PauloConstantino on June 21, 2017, 05:42:45 amIf I were you, try to build an existing synth, like a Roland TB-303.. the schematics are all over the place , I designed a rudimentary TB-303 VST plugin for Cubase SX and even that was tough 2001, it was uncompleted and I spent a year trying to get the Accent, and Filter shapes correct. so good luckAs tip look into this (if you change your mind about the DSP part)http://musicdsp.org/archive.php

author: PauloConstantino
author_rank: Regular Contributor
timestamp: June 21, 2017, 05:44:42 pm
content: Quote from: diyaudio on June 21, 2017, 04:31:20 pmYou said it took you a year.... Why ? Did you lack knowledge of fourier series or what ?

author: diyaudio
author_rank: Frequent Contributor
timestamp: June 21, 2017, 05:51:19 pm
content: Quote from: PauloConstantino on June 21, 2017, 05:44:42 pmat the time both. its 2017 today.

author: PauloConstantino
author_rank: Regular Contributor
timestamp: June 21, 2017, 06:13:12 pm
content: Quote from: magetoo on June 21, 2017, 12:16:07 pmDamn. This is why this forum is the best in the internet no doubt. Always great replies. Thank you for all the resources. Seriously, lectures on designing synths... That's fascinating !!!!Dude thank you so much! I'm going to study this in depth now!!

author: pitagoras
author_rank: Regular Contributor
timestamp: June 22, 2017, 12:45:33 am
content: my link collection, copy paste from my evernote, you might need to dig a bit.Dave Smith Instruments Prophet 6Analyzed herehttp://polysynth.tumblr.com/post/134667237805/a-quick-tour-of-the-prophet-6-voice-cardhttp://electronics.stackexchange.com/questions/34970/design-for-an-analogue-oscillator-that-doesnt-drift-in-frequencyMicromoog service manualhttp://www.cyborgstudio.com/synthmp3s/moog/micromoog/manual/micromoogmultimoogservicemanual.pdfBuilders/Kits/DIYhttp://musicfromouterspace.com/https://docs.google.com/file/d/0B3wD73e_RyWdbFlUbEpqeExRa0U/editHybrid, polyphonic, discontinued:http://mutable-instruments.net/ambikaKIT MOOOG!!!!!https://www.residentadvisor.net/reviews/16773VCOhttp://www.birthofasynth.com/Thomas_Henry/Pages/VCO-1.htmlhttp://www.allaboutcircuits.com/projects/diy-synth-series-vco/https://www.gearslutz.com/board/electronic-music-instruments-electronic-music-production/1111463-how-do-continuously-variable-oscillators-work.htmlCIRCUITShttp://www.univertron.com/SAS/manuals/RSF/Kobol%20Expander%20Schematics/continuously variable waveformContinuously variable waveshape:See Moog sub 37https://www.gearslutz.com/board/electronic-music-instruments-electronic-music-production/800682-best-favorite-diy-analog-synth-kits.htmlElectronic music & microprocessors bookhttps://github.com/rabidaudio/synthesizer/blob/master/reference/Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987.pdfSee also this: Moog 32 semi modularPLL Based enhttp://www.birthofasynth.com/Thomas_Henry/Pages/X-4046.htmlseems appreciated:http://randomsource.net/modulesSomeone did some modular:http://people.carleton.edu/~jellinge/mysynth.htmlhttp://www.cgs.synth.net/modules/cgs92_ssg.html

author: DaJMasta
author_rank: Super Contributor
timestamp: June 22, 2017, 01:03:02 am
content: At least for the keyboard component, even if you're going to replace the guts with your own stuff.... get a commercial keyboard as your base.Especially if you want weighted or velocity sensitive keys (which are quite important to regular piano playing, though often are less important to some kinds of synths), having a commercial product take care of the actuation, rigidity, and matching could be a huge improvement over homebrew input methods.While full analog is an option, I wouldn't be so quick to shun the digital option... mainly because you still end up doing a fair amount of analog design for the inputs to your ADCs and outputs of your DACs, there's a lot of analog stuff to be learned there and it can be very, very helpful to use midi controls or interface with software - for debugging and interfacing, sure, but also to let you play around with effects before trying to build or program them into your hardware. Going from a cool sound in a virtual synth pack to a basic DSP with a digital output is going to be a lot easier than trying to recreate it in analog, so if you want something other than the sound of established analog synth circuits, it could involve a whole lot of tweaking and adjustments.

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 22, 2017, 12:22:36 pm
content: Quote from: DaJMasta on June 22, 2017, 01:03:02 amCasio.Quote from: DaJMasta on June 22, 2017, 01:03:02 amUntil you find out that float dont works and all have to be integer math, no copy paste.

author: Lee Leduc
author_rank: Regular Contributor
timestamp: June 22, 2017, 01:02:50 pm
content: Thomas Henry has published many Synth Circuit Designs on the WEB. Many people consider is designs to be very good.Do a google search for "Thomas Henry Synth" and you'll find some of his designs. You can find people posting YouTube videos of His circuits.Here's a video of his 555 timer based VCO.His "An Analog Synthesizer for the 21st Century" at is a good start for a basic Synth.http://www.lulu.com/shop/thomas-henry/an-analog-synthesizer-for-the-21st-century/paperback/product-20192513.htmlHere's a schematic he published of his 555 timer based VCO.http://electro-music.com/forum/viewtopic.php?t=54623

author: Kjelt
author_rank: Super Contributor
timestamp: June 22, 2017, 01:06:07 pm
content: Analog ? To get in tune you have to tune the darn things every half hour.Digital hell yeah! Use one microcontroller for sound generation per key, I have been thinking about that but a bit costly to use 32 bit micros , 8 bit could be done, modular and a big rack with big PSU.Only the time........

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 22, 2017, 02:00:10 pm
content: Quote from: Kjelt on June 22, 2017, 01:06:07 pmI wanto do that one day, for every 2 voices use 1 DSPIC ( 16 bit stereo DAC ), all connected with SPI to a 40 pin 8 bit controller,then have analog resonant filter + analog enveloppes + voltage controlled amplifier per voice,phase modulation, phase distortion, or lookup-table synthesis thru analog circuits,will be my biggest and most expensive synth ever build, 5 euro for each DSPIC.Analog oscillators always sound better ofcourse, you need to tune them alot because tempco reistors are not available anymore ?,with the correct tempco`s and a lot of testing it can be done ?, how would you solve that without the tempco`s.

author: Lee Leduc
author_rank: Regular Contributor
timestamp: June 22, 2017, 04:05:45 pm
content: Thermistors or NTC's can be used to temperature compensate VCO's. These are cheap, available at 1% tolerance from Digikey. I sandwiched one of thesebetween the two transistors of the exponential converter using epoxy.https://www.digikey.com/product-detail/en/vishay-bc-components/NTCS0805E3472FMT/BC2576CT-ND/2237413A tutorial on exponential convertors and temperature compensation athttp://www.schmitzbits.de/expo_tutorial/shows how.Most NTC manufacturers have application notes describing how to linearize their response. I used this technique in a VCO I designed about 20 years ago.It worked very well.

author: Fungus
author_rank: Super Contributor
timestamp: June 22, 2017, 08:50:54 pm
content: Quote from: JanJansen on June 22, 2017, 12:22:36 pmFloating point DSPs have been reasonably cheap since the early 1990s.This one is still in production:http://www.analog.com/media/en/technical-documentation/data-sheets/ADSP-2101_2103_2105_2115.pdf?doc=AD7475_7495.pdf

author: BrianHG
author_rank: Super Contributor
timestamp: June 22, 2017, 10:14:51 pm
content: Quote from: JanJansen on June 22, 2017, 02:00:10 pmAt only 2 channels per DSPIC, with a very fast DAC, you have enough processing power to replicate an analog synth to the point where it would be indistinguishable from an analog synth. You should be able to do 4 to 8 channels with a cheap CD audio grade DAC.

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 07:00:42 am
content: Quote from: BrianHG on June 22, 2017, 10:14:51 pmYep, at some point the 'analog' part can be simulated so well you can't tell the difference. It's just a case of processing power. 192kHz simulation is probably enough for sound.nb. You can still output at 48kHz, 16bit.

author: Kjelt
author_rank: Super Contributor
timestamp: June 23, 2017, 09:35:24 am
content: You all know the story of the retired synth buidling expert from Roland who as hobby built a 8 bit synth that now went into production?https://www.roland.com/global/promos/roland_boutique/interview_3/Like to do something similar but then with a 8 bit uC for each key *if only I had the time , sigh*

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 10:46:21 am
content: Quote from: Kjelt on June 23, 2017, 09:35:24 amI'm sure his "connections" had something to do with it going into production.Quote from: Kjelt on June 23, 2017, 09:35:24 amWhy do you need one per key? You just need a bank of them and one other master uC reading the keyboard and telling them what to do.

author: John B
author_rank: Frequent Contributor
timestamp: June 23, 2017, 11:14:06 am
content: Nothing easy about digital synths. After reading stuff written DSP engineers at native instruments, building top notch sounding synths really does require top notch engineers. They've got the blend of scientific expertise and artistic streak too... Ive had a taste of it at the software level. Anyways.Maybe expand on what you would like to do as an overall goal? If you're reinventing a keyboard for the sake of learning how they work, then cool. However creating interesting and unusual sound generating electronic devices with something other than a keyboard as a controller would make you quite popular with some university composition students who are dabbling in new/experimental written or improvised music. Even if what you do could be reproduced on a computer, there's a slight hipsterish aspect to having retro equipment generating sound. Its all part of the performance.

author: Kjelt
author_rank: Super Contributor
timestamp: June 23, 2017, 12:42:02 pm
content: Quote from: Fungus on June 23, 2017, 10:46:21 amYeah but what do I then do with the reel of 200 pieces of 8 bit micros in my storage?

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 01:06:51 pm
content: I just discovered this guy on Youtube:Thought I'd plug him.Apparently he's built most of that stuff himself. He doesn't look old enough to me, but...He even has an oscilloscope and signal theory tutorial:

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 01:23:53 pm
content: Just reading some of the mad things he does in his synthesizers, eg. clock an Arduino synth using a 555 timer then ramp the clock speed up and down with a potentiometer for pitch change - it's completely 'analog'(!)

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 23, 2017, 04:33:30 pm
content: Quote from: Lee Leduc on June 22, 2017, 04:05:45 pmThank you, i have to read about this, making these thermistors linear for VCO, if i cant find out i will make a topic about this, thanks.Quote from: BrianHG on June 22, 2017, 10:14:51 pmI am using DSPIC33FJ128GP802 with build in stereo DAC ( delta sigma ).And yes i get 4 voices out of it ( @ 44K1Hz ) with the free compiler, when upgrading compiler i should be able to get 8 voices polyphony.( i,m to much still a beginner to have external DAC )What 16 bit audio DAC do you recommend to buy, i dont wanto harvest it out of old CD players.Once i get busy with 32 bit i need external audio DAC, since there are currently still no 32bit PICs with audio DAC.Quote from: Fungus on June 23, 2017, 07:00:42 amIf a analog noise-generator is used for random values in the chip, yes, then you can fool me with digital, else it sounds predictable.Quote from: Fungus on June 23, 2017, 10:46:21 amExact, dont need 128 chips, only the max nr voices you wanto play together.The only problem i see is how to implement the LFO ?, do you use the ADC on all chips to sample the LFO ?Quote from: Fungus on June 22, 2017, 08:50:54 pmOk, the 32bit PICs seem to also have fast float supported.I use this DSPIC wich has very slow float, impossible to use for realtime performance.I made everything integer, it is more accurate then using float.When using other chips with float support i can imagine it is still better to use integer math, if you have enough size for all lookuptables.

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 07:37:11 pm
content: Quote from: JanJansen on June 23, 2017, 04:33:30 pmI imagine you recreate the LFO on every chip.

author: Fungus
author_rank: Super Contributor
timestamp: June 23, 2017, 07:40:45 pm
content: Quote from: JanJansen on June 23, 2017, 04:33:30 pmOnly if it's a lookup table.It's all really just a case of processing power, run a random number generator with a high enough period and it won't repeat.

author: BrianHG
author_rank: Super Contributor
timestamp: June 24, 2017, 02:28:06 am
content: Quote from: Fungus on June 23, 2017, 07:40:45 pmYup, running a 2 different 96 bit shifting random number generators, 1 summing & 1 xor with the right 2 coefficients, results xored together, using any middle 16-32 bits as your random integer will make a non-repeating random noise generator. You may use 2 or 4 of each 72 bit result to get more than 1 different random number at the same time.Programming this properly in assembly for a PIC32 will get this random number down to around 20 clock cycles + 9 words of ram.Programming this in C will be tricky to achieve the same efficiency as assembly since it's mostly 96 bit rotates/adds&xors with a few fixed numbers.Simpler smaller random number generators exist, but, the patterns are predictable to the ear, especially 8 bit, 16 bit and 24 bit varieties. Even 32 bit for the simpler varieties.

author: Fungus
author_rank: Super Contributor
timestamp: June 24, 2017, 10:23:41 am
content: Quote from: BrianHG on June 24, 2017, 02:28:06 amI don't know if 96 bits is needed bu that's the principle - run 2 or 3 simple generators and combine them.https://en.wikipedia.org/wiki/KISS_(algorithm)RC4 is very efficient on 8-bit machines if you've got a 256 bytes of RAM to spare:https://en.wikipedia.org/wiki/RC4

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 24, 2017, 01:45:49 pm
content: What i mean is analog noise is not as perfect flat, makes unpredictable,you have to try it yourself.

author: BrianHG
author_rank: Super Contributor
timestamp: June 24, 2017, 03:10:08 pm
content: Quote from: Fungus on June 24, 2017, 10:23:41 am64 bit + 32 extra bits at the top on the xor/adding shifting barrel means if you use all 64 bits as a result, they will still be absurdly random.

author: BrianHG
author_rank: Super Contributor
timestamp: June 24, 2017, 03:22:50 pm
content: Quote from: JanJansen on June 24, 2017, 01:45:49 pmYou can easily filter the results with a few additional multiply adds with a few words of ram. But, remember, the simple table, or basic 8/16/24/32 bit random number generators, especially the ones which are available to call in the 'C' compilers are not that flat at all. Putting them through an FFT leaves peaks and bumps which is how at times engineers reverse engineer random number generators. Even when I've done some 2D noise filters using them on images left distinct patterns in the picture if the background was all black with just the right amount grey grain. Sorta why I had to learn about the larger 64 & 96 bit DIY random number generator varieties. They do make a real difference. Unless your 8/16/32bit MCU signal generator was programmed by someone looking into random number generation at cryptography levels, they will all have the flaw of using simple patterns or using existing basic RND 'C' calls to achieve their noise and it will show (be audible) in when attempting to synthesize analog sounds since each cycle is calculated to a perfect clock. This cannot happen in a true analog domain, or, you need a good enough random number generator to replicate the true analog domain effect. If you want a filtered noise, like pink noise & a high pass on the VLF frequencies, this is all to easy to do if you put in the effort.Note that all the most annoying aspect replicating patterns of the standard C RND functions used are mostly in the VLF domain which vanishes in the 96bit generator. Combine this VLF with pitch bending in a synth does create a audibly traceable crap effect just like when I tried to use the same RND on my 2D images when the resolution and brightness mix was just right.If you don't believe how bad the current state of the RND generators are and that they are truly behind what you are hearing, go to this website and just scroll down to the 2 images in the middle of the page:http://boallen.com/random-numbers.htmlUse that in your synth, and it will leave audible artifacts, because the noise isn't actually white of flat at all & there is a repetitive nature to it.I mean just look at how lousy that 32 bit floating point random number generator is. You cant say that noise is truly white...

author: GK
author_rank: Super Contributor
timestamp: June 26, 2017, 05:56:44 am
content: This discussion in the context of synth noise generation isn't making a lot of senseA maximal-count LFSR (linear feedback shift register) will repeat its bit sequence every (2^n)/2 clock cycles, where n is the number of register bits.So a 24-bit LFSR clocked at 44kHz will repeat its bit sequence every 190s. Nobody has the auditory memory to pick up on that.For 96 bits that increases to 900320028571185654472090s.

author: helius
author_rank: Super Contributor
timestamp: June 26, 2017, 06:18:43 am
content: LFSRs are common in hardware implementations. They are rather inefficient in software: unless your processor has very complex instructions, it needs to do three instructions (a shift, a mask, and an xor) per tap. For a 24-bit shift register with 8 taps, that is 24*8*3 = 576 instructions per word output. Times 44.1 kHz is already 25.4 MIPS; this is a stupid way to use a processor.

author: GK
author_rank: Super Contributor
timestamp: June 26, 2017, 06:53:40 am
content: Quote from: helius on June 26, 2017, 06:18:43 amThe "word" does not repeat every 1/44100 s - only one bit is shifted out per "clock" cycle. Make that 1.05 MIPS. And you don't need 8 taps either; just choose an adequate shift register size that requires less taps for "maximal" count. And if you don't require your noise to be white right up to 20kHz you can get away with a bit rate much less than 44k. I only picked 24-bits and 44k as an example to put perspective on the bit sequence repetition rate.

author: Someone
author_rank: Super Contributor
timestamp: June 26, 2017, 07:33:33 am
content: Quote from: GK on June 26, 2017, 06:53:40 amExactly, you can select efficient polynomials which are easier to implement on the chosen platform, I'll see if I can find the AVR examples I came up with that were all just a few instructions per byte.

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 07:58:22 am
content: Quote from: GK on June 26, 2017, 05:56:44 amCheck the image in my above posted link of Microsoft's 32bit number generator. Tapping the MSB shows that repeated 1 bit pattern. The full blown 24bit number generator in your example may not repeat for 190s, but, within that, the loudest part of the signal, which is the most important part to our ears, may be repeating once a second or faster.I chose a cheap version of a 96 bit RND number generator which runs on a single shift of the 2 different bulks with nothing more than XOR and addition with 2 fixed integers since it can be cheaply adapted to a 16 or 32 bit MCU in only a few instructions running once. We are talking around 20 cpu clocks. This cheap ass quick method only reveals around 48 bits of true randomness, but creates wild noise very quick. A proper full 96 bit generator requires shifting and individual bit test + xor-ing, in addition to the second random generation which is based of bit-test and addition which makes a nasty loop eating up a ton of CPU mips for nothing, or, you can write this into an FPGA to do a full transform once every clock cycle.If you actually even tap bit 96 in a large random number generator, it will also seem to repeat on it's ow fairly quick as well. Luckily, I avoid this by using the center 32 bits which appear completely random on their own.

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 08:28:09 am
content: Quote from: BrianHG on June 24, 2017, 03:22:50 pmI always thought the standard random number generators were badon purpose- to force people to go out and find one that actually fits their application.(nb. there's no 'perfect' RNG).

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 08:39:34 am
content: Quote from: BrianHG on June 26, 2017, 07:58:22 amYep. ANY generator that cycles through all possible combinations of values in a sequence will have at least one bit that goes 010101010101010 and probably another one that goes 00110011001100110011, etc.At the end of the day it's just a complicated counter. Every bithasto follow some sort of a sequence.The way to overcome this problem is to XOR two (or more) unrelated RNGs together.https://en.wikipedia.org/wiki/KISS_(algorithm)

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 09:23:32 am
content: Quote from: Fungus on June 26, 2017, 08:39:34 amYour link has an error, I think the closing bracket needs to be included to show the proper wikipedia page.Yup, the 96 bit generator I use is actually 2 different 48 bit generators summed together.

author: GK
author_rank: Super Contributor
timestamp: June 26, 2017, 09:29:59 am
content: Quote from: BrianHG on June 26, 2017, 07:58:22 amI'm sorry, but this is just wrong. From (a reference immediately at hand) AOE 2nd ed, page 440:Quote

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 09:48:58 am
content: @GK, would you accept that in this document:https://web.archive.org/web/20161007061934/http://courses.cse.tamu.edu/csce680/walker/lfsr_table.pdfPage 1, table 1, the 24 bit LFSR-4 is the 24bit LFSR random number generator you are talking about?Or this one:http://www.xilinx.com/support/documentation/application_notes/xapp052.pdfPage 5, table 3, the 24 bit LFSR-4 is the 24bit LFSR random number generator you are talking about?(The 2 differ slightly by choosing 2 different bits to xor with the output, but they should be close)If so, give me this weekend and I will plot the monochrome results on a 2d B&W image and going a step further I'll plot another version using bits 24 & 23 to create 4 shades of grey to see if we have any visual pattern. If the results are a perfect snow, then yes, there would be no coincidental mixing artifacts with this noise generator mixed with other tones in a music synthesizer.If there are any visible patterns, these patterns will, when mixed with some tones or notes in a music synthesize create an audible artifact.Can we agree on this much?(I like these challenges and will admit defeat if I cant find any patterns...)

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 09:57:08 am
content: Quote from: BrianHG on June 26, 2017, 09:48:58 amIt probably will, but not necessarily.It all depends on how you choose the bits that go into the sound. As noted above, each bit in the RNG will follow some sort of a sequence.How audible the artifacts are will depend on the bits you choose for the MSBs of the sound samples.

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 10:03:40 am
content: Quote from: Fungus on June 26, 2017, 09:57:08 amIt's the nasty problem with synths that they usually use nice smooth pitch bends and wobbles with means if there are any hidden patterns in the noise, it will come in and out of the sound as phase go in and out. This is one of those things that only the users of the analog synths instruments will hear where as us, the public wouldn't notice a thing, or, if we do, we would believe it is the way it supposed to sound.

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 10:05:50 am
content: Quote from: BrianHG on June 26, 2017, 07:58:22 amEach of those 32 bits will follow its own pattern, just like bit 96.

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 10:09:14 am
content: Quote from: Fungus on June 26, 2017, 10:05:50 amIf it was a single 96 bit LFSR generator with only 4 xored bits at the top, yes. Since it is 2 different 48 bit generators, only one of which is a LFSR generator, the sum results breaks up the pattern.

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 10:11:19 am
content: Quote from: BrianHG on June 26, 2017, 10:09:14 amAh, OK, I'm confusing two threads.

author: BrianHG
author_rank: Super Contributor
timestamp: June 26, 2017, 10:26:01 am
content: Found my white noise code.It's actually a 43 bit LFSR generator xored with a 37 bit CASR random number generator, outputting 16 bits of the 80. I got the combination years ago from an online university R&D paper so I cannot take the credit for this particular combination which originally was in verilog, but the author did do analysis and repeat-ability of each bit individually and found that this was as random as it gets for it's size of bits.This is as white as I was able to get, sorry but it's programmed in verilog:Code:module white_noise ( clk, rst, ena, out );input clk, rst, ena;output[15:0] out ;wire [15:0] out = number_o[31:16] ;reg [31:0] number_o;reg [42:0] LFSR_reg;reg [36:0] CASR_reg;//CASR:reg[36:0] CASR_varCASR,CASR_outCASR;always @(posedge clk )beginif ( rst )beginCASR_reg = (1);endelsebeginif (ena) beginCASR_varCASR =CASR_reg ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_outCASR =CASR_varCASR ^CASR_varCASR ;CASR_reg = (CASR_outCASR );endendend//LFSR:reg[42:0] LFSR_varLFSR;reg outbitLFSR;always @(posedge clk)beginif ( rst )beginLFSR_reg = (1);endelsebeginif (ena) beginLFSR_varLFSR =LFSR_reg ;outbitLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ^outbitLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ^outbitLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_varLFSR =LFSR_varLFSR ^outbitLFSR ;LFSR_varLFSR =LFSR_varLFSR ;LFSR_reg = (LFSR_varLFSR );endendend//combinate:always @(posedge clk)beginif ( rst )beginnumber_o = (0);endelseif (ena) beginnumber_o = (LFSR_reg [31:0]^CASR_reg[31:0]);endendendmoduleI piped this thing through HD video at different resolutions and signal gains. Unlike the Xilinx LFSR code examples in my .pdf links 2 posts above, which at some video sizes made a pattern go through the video like an analog TV broadcast with a weak interfering radio broadcast over the channel, or adjacent still image, this random number generator was a pure non-patterned perfect grain.

author: Moshly
author_rank: Regular Contributor
timestamp: June 26, 2017, 10:42:29 am
content: Hi, Just thought I'd add this bit from an interview with Bob Yannes (Designer of the C64's SID chip)Highlighted part about noise waveform generation. Specifically -> The noise generator is implemented as a 23-bit-length Fibonacci LFSR (Feedback polynomial: x^22+x^17+1).Quote

author: GK
author_rank: Super Contributor
timestamp: June 26, 2017, 01:01:19 pm
content: Quote from: BrianHG on June 26, 2017, 09:48:58 amMate, I don't have the time or the energy to get into this in depth right now or follow all of your links, but I don't think I need to. Surely tens if not hundreds of thousands of laboratory-grade maximal-count-LFSR-based noise sources have been professional and semi-professionally manufactured since the 50s or the 60s when I believe HP popularized the technique.I've got a one here based on a PIC MCU that covers the audio frequency spectrum and the pseudo-random bit sequence generated is sufficient for the output spectrum to look completely flat and stable down towards DC as far as any available spectrum analyzer can see. And it sounds exactly so when I plug it into an amplifier and listen to it. A LFSR that is wholly adequate for audio-spectrum noise generation is a trivial thing to code in even the most crufty MCU in my experience.No offense intended, but I think that persisting to imply that such a well established technique (in both theory and practice) for generating noise that is for all practical purposes sufficiently random for a plethora of sensitive test and measurement purposes is otherwise intrinsically deficient for audio signal generation might be venturing into audiophool territory.

author: Fungus
author_rank: Super Contributor
timestamp: June 26, 2017, 01:24:52 pm
content: Quote from: GK on June 26, 2017, 01:01:19 pmYes, this has got slightly derailed. The original problem was that some non-analog synthesizers use a small lookup table to generate noise (because internally that's how they generate all their periodic waveforms).

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 26, 2017, 02:00:14 pm
content: With the super analog sounding 96bit noise generator plus the extra analog algorithm been suggested here would cost me at least 1 voice polyphony.I dont know if some manufacturers has all that fancy stuff in there, i,m not going to waste my DSPIC on some noise generator,i have to get started with 32bit chips + external DAC maybe that solves things a bit with more power, you cannot fake analog noise, all transistors sound different.Are you really making digital synthesizers sounding analog with this ?, lets hear it.

author: dave_j_fan
author_rank: Regular Contributor
timestamp: June 26, 2017, 04:12:03 pm
content: see midi versionscoin touch type

author: Fungus
author_rank: Super Contributor
timestamp: June 27, 2017, 11:15:00 am
content: Quote from: JanJansen on June 26, 2017, 02:00:14 pmIt's overkill, yes, but your claim was that: "If a analog noise-generator is used for random values in the chip, yes, then you can fool me with digital, else it sounds predictable."I'm sure there's a simpler/faster RNG that will be good enough for white noise. Itwillbe slightly CPU dependent though, what chip are you using?Quote from: JanJansen on June 26, 2017, 02:00:14 pmMore processing power is always good. Or ... use parallel chips if you want to stick with what you know. Parallel chips can scale to any amount of polyphony.

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 27, 2017, 12:05:02 pm
content: Quote from: Fungus on June 27, 2017, 11:15:00 amDSPIC33FJ128GP802Quote from: Fungus on June 27, 2017, 11:15:00 amJes i want that, it also sounds better.Small beginner problem : i still need to begin learning how SPI communication work to let the chips talk to eachother.Once i have the SPI i will be like a mad scientist.

author: Fungus
author_rank: Super Contributor
timestamp: June 29, 2017, 11:44:24 am
content: Quote from: JanJansen on June 27, 2017, 12:05:02 pmThat chip has plenty of RAM (16kb) so I'd think about using RC4 stream cipher for random numbers. It needs 256 bytes of workspace RAM but has cryptographically strong output and only needs a few clock cycles per byte.https://en.wikipedia.org/wiki/RC4If you're producing 16 bit samples then try using only 8 bits of random. This sounds counter-intuitive but less bits actually equates to "more noise!" in the signal processing world, which is exactly what you want.(eg. 'tape hiss' is just 'not enough bits' if you analyze it mathematically).This video shows it beautifully:If you insist on the full 16 bits then simply combine the byte output of RC4 with the byte which is 128 bytes away from it in the RAM buffer or something like that.

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 29, 2017, 02:27:23 pm
content: Hi, thanks, you have any C code for one frame ?

author: Fungus
author_rank: Super Contributor
timestamp: June 29, 2017, 03:10:05 pm
content: Quote from: JanJansen on June 29, 2017, 02:27:23 pmCode:void swap(int a, int b){unsigned char temp= s;s=s;s=temp;}unsigned char getbyte(void){i=(i+1)%256;j=(j+s)%256;swap(i, j);int index=(s+s)%256;return s;}

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 29, 2017, 03:36:57 pm
content: You serious ?, i,m not gonna use any modulo, what 3 modulo`s.

author: Fungus
author_rank: Super Contributor
timestamp: June 29, 2017, 03:46:51 pm
content: Quote from: JanJansen on June 29, 2017, 03:36:57 pmWhat do they teach kids in school these days?Modulo 256 is easy. I bet even your C compiler knows how to optimize it.Hint: If you declare i, j and 'index' as unsigned 8-bit variables then you can leave out the all modulus operations, it will work exactly the same.

author: JanJansen
author_rank: Frequent Contributor
timestamp: June 29, 2017, 04:12:42 pm
content: Ok thanks, will the output still be full 16 bit ?

author: Fungus
author_rank: Super Contributor
timestamp: June 29, 2017, 04:41:45 pm
content: Quote from: Fungus on June 29, 2017, 03:46:51 pmAs a test I compiled this code for Arduino (I don't have PIC installed):Code:byte i=0,j=0;byte s;void swap(byte a, byte b){byte temp= s;s=s;s=temp;}byte getbyte(void){i=(i+1)%256;j=(j+s)%256;swap(i, j);byte index=(s+s)%256;return s;}Note that there's a huge bug in that code that I randomly pulled off the 'net. The "swap" function has parameters called 'a' and 'b' but uses 'i' and 'j' in the code(!)The disassembled output from that is:Code:000000c0 <_Z7getbytev>:c0:80 91 11 02ldsr24, 0x0211c4:8f 5fsubir24, 0xFF; 255c6:90 e0ldir25, 0x00; 0c8:80 93 11 02sts0x0211, r24cc:fc 01movwr30, r24ce:e0 5fsubir30, 0xF0; 240d0:fe 4fsbcir31, 0xFE; 254d2:80 81ldr24, Zd4:e0 91 10 02ldsr30, 0x0210d8:e8 0faddr30, r24da:e0 93 10 02sts0x0210, r30de:f0 e0ldir31, 0x00; 0e0:e0 5fsubir30, 0xF0; 240e2:fe 4fsbcir31, 0xFE; 254e4:e0 81ldr30, Ze6:e8 0faddr30, r24e8:f0 e0ldir31, 0x00; 0ea:e0 5fsubir30, 0xF0; 240ec:fe 4fsbcir31, 0xFE; 254ee:80 81ldr24, Zf0:08 95retNo modulus operations in sight, the compiler simply ignores them! (as predicted)Edit: Out of interest I didn't initialize the state table the first time I tried it and the compiler optimized away the entire thing on the grounds that the table was filled with zeros and therefore unnecessary.ie. The table vanished from RAM and the getByte() function compiled to "i=i+1; return 0;"What exactly are they feeding those compilers these days?

author: Fungus
author_rank: Super Contributor
timestamp: June 29, 2017, 04:43:10 pm
content: Quote from: JanJansen on June 29, 2017, 04:12:42 pmCode:unsigned char getbyte(void){...}It was never 16 bits.

author: GK
author_rank: Super Contributor
timestamp: June 30, 2017, 02:50:42 pm
content: Quote from: GK on June 26, 2017, 05:56:44 amCorrecting myself here, that's every 2n-1 clock cycles. Don't know where I remembered (2^n)/2 from, maybe from some different kind of feedback arrangement, or perhaps miss-remembered.So the 24-bit counter would repeat every 380s rather than 190s. Incidentally a 20, 21, 22, 23, 25 or 28-bit maximal-count LFSR can be made with just two feedback taps (just a single xor).Here is a quick experiment it SPICE. It a 16-bit maximal-count (requiring 4 taps) LFSR clocked at 40kHz. a 10kHz 3-pole LPF filters the pseudo random bit stream and defines the noise bandwidth. I've used the .wave directive the record the output as a 16-bit 44.1kHz WAV file. The bit sequence repeats every (1/40k)*((2^16)-1) = 1.64sI recorded 5s worth. The LTSPICE *.ASC file and the WAV audio file are attached. Have a listen:https://www.eevblog.com/forum/projects/building-musical-synthesizers-and-keyboards/?action=dlattach;attach=328141For a good read on the power spectrum of pseudo random bit sequences see here:http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1967-09.pdf

author: homeless_peep
author_rank: Contributor
timestamp: August 04, 2017, 10:33:26 am
content: Sound generation (VCOs, noise, etc) and sound processing (filters, phasers,overdrives...) are generally good candidates for analog implementations. People will argue that DSP is more accurate, which is true, but the little nuances of analog circuits (pitch instability, possibly noise or intermodulations and so on) do make a difference and produce a character. Filters and distortions in particular sound absolutely shitty, empty and uninteresting on digital synths.VCOs are a very hard thing to nail. Exponential VCOs (1V/oct standard) are VERY depended on temperatures, which will be your greatest problem. Tempco resistors are a solution, but thermal oven compensation is more straightforward and works great (and maybe, better?).I suggest investigating the sawtooth core topology, because of it's low price and easy to find components. Triangle cores can be a bitch to perfect and are certainly more expensive.Filters come in all forms, prices, shapes, just google some and use a verified design. The moog cascade filter is an absolute classic in synths and it's not much of a hassle at all.VCAs can be designed in a number of ways, one of the most economical is to look at the LM13700 (or CA3080) applications.Distortions can be as simple as a diode clipper/fuzzer, but you can get more fancy if you care that much.Control signals (sequencers, LFOs, envelopes) can all be made with analog/discrete components, but since you have digital skills, just make them with a processor. You will have advanced functions like syncing to external tempo/clock, phase difference between LFOs, sequence save/recall etc. It is also considerably cheaper to do it that way.Various flavors of noise are used, a simple "white" one can be made using a couple of transistors and resistors.YUsynth has a ton of stuff and projects available on his website, along with schematics, boards and short explainations. There you can also find the full schematics of the microbrute and mini brute synthesizers. Both are commercial, low cost synths that combine analog and digital methods (analog sound-digital control. kind of.) and can teach you more about synthesizer systems architecture.Knowing the LM13700 is an absolute must in this field, as well as differential pair applications in general. Have a SPICE simulator by your side at all times- it will help you a lot.