Author |
Message |
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Wed Dec 18, 2019 8:59 am Post subject:
TR909 snare planning Subject description: TR909 snare planning |
|
|
Hi, i want to build a TR909 snare next year.
There is a 2sd1469 in the diy9090 schematic,
what transistor can replace it ?, is it important to the sound ?
And how do you make the noise generator with available parts ?
I dont want to use a MCU for the digital noise, i like to clone the original.
The 4006 is not available, i read somewhere you can buy them in different packages to do exact the same thing ?
And what are those other parts that say "31" ?
Anyone got links ?
thanks |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Fri Dec 20, 2019 2:10 pm Post subject:
Re: TR909 snare planning Subject description: TR909 snare planning |
|
|
VA1 wrote: | Hi, i want to build a TR909 snare next year.
I dont want to use a MCU for the digital noise, i like to clone the original.
|
Given that the original uses a 32-stage shift-register based noise generator that produces digital noise, why is an MCU not an option? Seems to me it'd be the easiest/cheapest way to copy the original noise gen exactly - and it would be *exactly*. You could have the same sequence of bits at the same rate.
But then, I would say that, wouldn't I?!
https://electricdruid.net/which-noise-chip-do-i-need/
Still, amongst all those, I don't have one that copies the TR909. You'll have to program that yourself - sorry! _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 8:22 am Post subject:
|
|
|
Oh you mean to emulate the exact thing ?, sound like a good plan.
To me its unknown parts, i dont know how it works.
I thought : MCU noisegenerator is just a rand() function to a DAC.
What is the rate from this tr909 noise generator circuit ?, i dont see it.
Oh and by the way : is this noise generator a good project to start with FPGA ? |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Sat Dec 21, 2019 8:45 am Post subject:
|
|
|
VA1 wrote: | Oh you mean to emulate the exact thing ?, sound like a good plan.
To me its unknown parts, i dont know how it works.
|
Fair enough. No reason why you should! The TR-909 noise generator is a hardware implementation of a "Linear Feedback Shift Register" (LFSR). In this case it's a 31-bit register (the last few stages don't do anything except delay the output very slightly). They've taken feedback taps at stage 13 and stage 31, which gives a maximal length sequence of random bits, so 2^31 bits.
Since the circuit is digital in nature, it's possible to copy the same algorithm in firmware and output the same bit sequence. We use four bytes to store the 31-bit shift register, then take the values from the correct bits for the feedback, and then shift the register one bit over and put the feedback in at the bottom.
Not that you'd notice if we used a slightly different random bit sequence, honestly...but there's something slightly warm and fuzzy about making the copy exact, isn't there?!
Quote: |
I thought : MCU noisegenerator is just a rand() function to a DAC.
|
Well, that is pretty much true. But it glosses over a lot of details in what exactly goes on inside that "rand()" function! In this case, that's what our LFSR is doing.
Quote: |
What is the rate from this tr909 noise generator circuit ?, i dont see it.
|
Below the two 4006 chips is a small clock circuit built around two more gates from the 4070 XOR chip. It clocks the shift registers at about 300KHz according to my experiments on the breadboard. The value of the 100pF cap is probably at least +/-10% and more likely +/-20%, so it's not critical. Also I found different brands of 4070 ran at slightly different rates (one was 5% faster than the other - HCF4070BE vs CD4070BE).
If we output the 2^31 bits at 300KHz, we get random white noise for just slightly less than two hours (119.3 minutes) before the sequence repeats.
Quote: |
Oh and by the way : is this noise generator a good project to start with FPGA ? |
You could certainly do it, but it's serious overkill.
I've been playing with the idea and it looks possible on a PIC 12F1501, which is a little 8-pin chip. It runs at 4MHz instruction rate and can produce an output at 285KHz, which is only 5% lower than the hardware version, and within the error of the original design. Given that it produces flat white noise out to around 100KHz, I don't think there's any chance of differences being audible. _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 8:59 am Post subject:
|
|
|
Ok thank you.
How does the original circuit output the noise on what bitrate ?
How do you output the noise from a PIC ? |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 9:04 am Post subject:
|
|
|
|
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Sat Dec 21, 2019 10:32 am Post subject:
|
|
|
VA1 wrote: |
How does the original circuit output the noise on what bitrate ?
|
It's a series of on/off digital bits coming out of pin 9 of IC33. The register is clocked at ~300KHz, so the bits come out at that rate.
You can see the clock based around gates 'b' and 'a' below the shift registers, and then you can see the two feedback taps (both taken from pin 10 of the registers) that go to XOR gate 'c' and then feedback into the input of the register (pin1). The rest of the circuit is that stuff on the left which is just to make sure it doesn't boot-up with all zeros (if it did, no noise would come out!)
Quote: |
How do you output the noise from a PIC ?
|
The same way - it's just a series of random bits fed to an output pin. _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 10:42 am Post subject:
|
|
|
Nice, so the noise has 1 bit output.
I did not thought this, i was thinking analog with a DAC.
Then i think it will be good, just shift a 32 bit value and add the XOR of 13 and 31 position ?
Ok.
Very nice it saves alot of parts and space. |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Sat Dec 21, 2019 10:51 am Post subject:
|
|
|
VA1 wrote: | Nice, so the noise has 1 bit output.
I did not thought this, i was thinking analog with a DAC.
|
It *is* a bit weird, but you can think of it as a 1-bit DAC! It's the average level over time that varies randomly, and the ear provides the averaging.
Quote: |
Then i think it will be good, just shift a 32 bit value and add the XOR of 13 and 31 position ?
|
Exactly. You shift the register, then put the XOR'd bit into the empty bit.
Quote: |
Very nice it saves alot of parts and space.
|
It certainly does! _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 10:56 am Post subject:
|
|
|
Dont i have to initialize the register ?
It handles itself right ? |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Dec 21, 2019 11:08 am Post subject:
|
|
|
Oh wait, is the XOR bit taken after the shift or before ? |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Jan 11, 2020 2:51 am Post subject:
|
|
|
Ok i finally finished the noise generator in a PIC12F615 running at 8MHz.
I got it running at 3 KHz, i dont know how to make it 100 times faster.
What kind of mad ASM skills do i need ?
Anyways i was playing with this noise generator and you can get very nice noises with changing the feedback-bits.
Freaky roar sounds and beeps + repeating noises. |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sat Jan 11, 2020 5:34 am Post subject:
|
|
|
I calculated wrong, i am running the noise at 12K.
I just increased it to 15K max
If i take a 32MHz chip i can get 60K max. |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Sat Jan 11, 2020 1:48 pm Post subject:
|
|
|
With the chip running at 8MHz, you've only got a 2MHz instruction cycle, so that doesn't give you much time. Say we're aiming for 100KHz output rate - that's only twenty instructions. Still, for a basic LFSR in assembly, that's possible.
How long is your code?
Here's an example (this was done on a 12F675)
Code: |
; 31-bit LFSR with taps at 31 and 28
;----------------------------------------------------
swapf LFSR1_4, W ; Get bit 28
movwf TEMP
rlf LFSR1_4, W ; Get bit 31
xorwf TEMP, F
; Shift the XORd bit into carry
rlf TEMP, F
; Shift the register
rlf LFSR1_1, F
rlf LFSR1_2, F
rlf LFSR1_3, F
rlf LFSR1_4, F
; Output the noise bit
movf LFSR1_1, W
movwf GPIO
|
_________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sun Jan 12, 2020 6:56 am Post subject:
|
|
|
I am making a new project now i spend the whole night yesterday : UART controlled noise generator.
The xor bits can be selected and the pitch can be set.
I am making all options available, taking xor from all combinations possible,
i dont need the high beep tones, the roaring electric beep sounds i save with the noises.
There are many noises that has tones hidden in it, small soft glitches, have to sort them out later.
What a fun you can have with a small chip.
I go get the inner core code from my workcomputer for you now, wait a minute. |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sun Jan 12, 2020 7:06 am Post subject:
|
|
|
union ShiftReg{
unsigned long value;
struct{
unsigned b10:1, b11:1, b12:1, b13:1, b14:1, b15:1, b16:1, b17:1;
unsigned b20:1, b21:1, b22:1, b23:1, b24:1, b25:1, b26:1, b27:1;
unsigned b30:1, b31:1, b32:1, b33:1, b34:1, b35:1, b36:1, b37:1;
unsigned b40:1, b41:1, b42:1, b43:1, b44:1, b45:1, b46:1, b47:1;
};
}shiftreg;
void init()
{
shiftreg.value = -1;
}
for( ;; )
{
if( TMR1IF )
{
TMR1ON = 0;
TMR1IF = 0;
TMR1 = -( 33 + pitch.frequency );
GIE = 0;
TMR1ON = 1;
PORTA = shiftreg.byte1;
feedback = shiftreg.b47;
feedback ^= shiftreg.b25;
shiftreg.value <<= 1;
shiftreg.b10 = feedback;
GIE = 1;
}
}
} |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Sun Jan 12, 2020 7:33 am Post subject:
|
|
|
Oh the GIE has to be before setting the timer btw.. |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Wed Jan 15, 2020 2:36 pm Post subject:
|
|
|
It looks pretty efficient to me (at least for C!).
The only way you'd manage to get that to go faster would be to have a look at what it compiles into, and then see if altering things makes the resulting assembly longer or shorter. Is it worth it? Only you can decide.
I don't know enough about how the compiler assembles things like your Struct, but it's possible there would be a simpler way to get specific bits there.
That said, your way is *variable*, which is generally more costly in terms of time than a single specific situation, where you can fine-tune the code for just that situation.
Often I've chosen tap sequences based on where in the byte the feedback bits fall in order to minimise the bitshifting required to XOR them together. For example, if both bits were the 6th bit in the byte, you could XOR the two bytes directly and then use the 6th bit as the result. If one bit was the 4th bit in the byte and the other was the 6th, you'd have to shift one of them twice (or shift both of them once) to get them to line up before you could XOR them. Obviously, there are lots of ways you can do this, but this gives you the general idea - a specific situation can be heavily optimised, a general situation not so much. _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
VA1
Joined: Aug 20, 2018 Posts: 98 Location: Nederland
|
Posted: Thu Jan 16, 2020 8:06 am Post subject:
|
|
|
I know i want to build the hardware version one day for the drums.
This noise PIC project i could spend a whole year, i still dont have perfect noise without glitches.
What would the HW version reset its bits to ?, random at startup ?
I made a LUT of 128 choises for the reset value, it is not enough.
Now i have to build a edit function for all 32 bits and i gave up.
It has some nice drums is pitch envelop is used, retrigger also gives nice sounds.
I like to make a single OTA stereo panning thing for these noises.
Together with a super small VCF, the smallest i can build.
Need to add another small chip for LFO and ENV.
I better spend time perfecting my already build synth. |
|
Back to top
|
|
|
Electric Druid
Joined: Mar 13, 2012 Posts: 44 Location: UK
|
Posted: Thu Jan 16, 2020 8:31 am Post subject:
|
|
|
VA1 wrote: | This noise PIC project i could spend a whole year, i still dont have perfect noise without glitches.
|
Whether you get glitches depends on the sequence. Not all feedback bit positions produce maximum length sequences - most don't, in fact. Those "degenerate" sequences will repeat quicker and give all sorts of weirdness. That can sometimes be a good thing!
Quote: |
What would the HW version reset its bits to ?, random at startup ?
|
Ideally, I suppose it should be seeded by some random value (like noise from an ADC input or something) but I have to say I've never bothered.
Quote: |
I made a LUT of 128 choises for the reset value, it is not enough.
Now i have to build a edit function for all 32 bits and i gave up.
|
There's certainly a lot of possibilities with a 32-bit register!
Quote: |
It has some nice drums is pitch envelop is used, retrigger also gives nice sounds.
|
Yeah, you can do some interestingly weird pitched sounds if the sequence resets at an audio rate.
Quote: |
I like to make a single OTA stereo panning thing for these noises.
Together with a super small VCF, the smallest i can build.
Need to add another small chip for LFO and ENV.
I better spend time perfecting my already build synth. |
Sounds like a good project. Good luck with it! _________________ Electric Druid Synth and Pedal DIY website |
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
Posted: Thu Jan 16, 2020 10:14 am Post subject:
|
|
|
This subject has been at least on SDIY, that is, the idea of getting glitch free noise from an LFSR (this is a shift register type pseudorandom noise generator). The more bits and the faster you run it, the higher the quality of noise will be. Personally, I use no fewer than 32 bits and I get very clean noise at normal audio sample rates. However, I also use fast microprocessors (STM32F and STM32H) which will do it without breaking a sweat.
There are also techniques that can be used with less bits to make the stream more random. This amounts to using two LFSR registers of different lengths and then you can do things like interleave the bits. For example, an 8 bit and a 7 bit LFSR could potentially be as good or better than a 15 bit register. The drawback is that like using a longer register, the fact that you're doing two LFSR actions for each new random number, it is slower than just using a single 8 bit register which as you know can sound like chuff-chuff-chuff... _________________ 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
|
|
|
Moosgummi
Joined: Feb 01, 2015 Posts: 15 Location: Hiltown, Germany
|
Posted: Mon Jan 27, 2020 12:27 pm Post subject:
|
|
|
Oh wow,
I had a plan to build the coolest CMOS LFSR ever with 159 bits, using a 128 bit SR (probably 4562, my favorite CD4*** site disappeared, and my CMOS box is just a box with bags and numbers) and a programmable SR (4557?) set to 31 bits.
But now I see just the 31 bits alone give me 2 hours of noise @ 300kHz, so that seems excessive...
Cool nonetheless! |
|
Back to top
|
|
|
CHRISKELLY
Joined: Apr 08, 2018 Posts: 103 Location: England
Audio files: 3
|
|
Back to top
|
|
|
|