Jump to content

Making sound with a core


mess

Recommended Posts

Hi,

I made a very simple synth out of a core last night,

it generates a square wave when you send a note from a keyboard on midi channel one

since I didn't have a dac this first version outputs a square wave on J14

the required output circuit:

      100n  10k

J14---||--\/\/\-------------

                        |          |  _______ sound out

                        == 10n    >/

                        |        _/<  100k pot, log

                      _|_        _|_

 

you can find the code here:

http://webs.hogent.be/~032573mh/coresound_v0_1.zip

Michaël

Link to comment
Share on other sites

Hey Michaël,

that's great! :D

I read a lot about subtractive synthesis and harmonics while writing the SpeakJet application (combined the five oscillators to a waveshaped harmonic sound). Basically it's about combining different OSCs with doubled frequencies but with dedicated volume-relations within.

It looks like you aready know all this stuff... :-\  but if not, these are two quite interesting readings :) :

- the synthesis tutorials at the end are pretty good:

http://www.samplecraze.com/tutorial.php

- and the same in short: how to create complex sounds

http://carini.physics.indiana.edu/P105/Synthesis.html

Michael

Link to comment
Share on other sites

That is cool! Does it generate the note that you press, or just 'a' note??

It generates the note you press, you can play any note up to B6...

if you can make it do different waveshapes

I have a newer version with PWM, you can set initial duty cycle and modulation speed,

this sounds a lot more interesting already

I don't have a tuner here so I can't comment on accuracy

It's really just a toy that's a lot of fun and very easy to make

In the meantime, I have found a parallel 8 bit dac,

so I can make all kinds of shapes: sine square saw triangle

I'm gonna try to implement an envelope tonight...

Thanks AC for the links I'm going to look into those...

the second one seems like fourrier analyses/synthesis

I guess that would be a bit too much for the pic to handle in C  :)

Link to comment
Share on other sites

I'll leave the fourier synthesis to my k5k, but I was thinking.... I wonder if this could be ported to a 16F88 module, controlled by IIC ? Could be a good basis for a DCO synth if you stacked the osc's up...

Forgive me, I haven't read the code... Flat out at the moment :(

Link to comment
Share on other sites

Hi,

I made a very simple synth out of a core last night,

it generates a square wave when you send a note from a keyboard on midi channel one

since I didn't have a dac this first version outputs a square wave on J14

the required output circuit:

      100n  10k

J14---||--\/\/\-------------

                        |          |  _______ sound out

                        == 10n    >/

                        |        _/<  100k pot, log

                      _|_        _|_

 

Damn nice!!

Midibox is going modular  ;D

MfG

Link to comment
Share on other sites

just a thought:

a synthesizer to go. Battery-fed, size of a cigarette box, SMD ,integrated loudspeaker,..2-3 octaves, a modified cheap mp3-player with recording-function, record your musical ideas whenever you got them, wherever you have them,... nothing special, 1OSC, 1LFO, (1 ADSR), no filter,...

this could be much better than my pot-theremin.. (one button for on/off, pot for frequency, NE555, 2 resistors, 1 capacitor)  :)

Link to comment
Share on other sites

Excellent work!  I'm glad to see someone making progress on these concepts!  Sadly my grand wavetable DCO plans never made it to the ASM stage due to lack of time.  :'(

Using a separate module over IIC would work well, as one could conceivably just add some extra voices by adding more modules.  Plus the MIDI/interface handling of the Core takes up a lot of the potential processing power.

Once you start applying modulation to the various parameters (ie via LFOs, ADSRs, etc.), not having the multiplier in a 16F88 would be a problem.  However, even a 18F252 (or something with more flash, if you're going wavetable) would work just fine.  PWM output is good, as would be an 8-bit (or better) R2R ladder - forget about DACs, they're too pricey!  ;)  I considered combining the two approaches, but I couldn't figure out how to apply an envelope to the PWM portion.

Doing a filter in software requires effort and knowledge of signal processing concepts.  That was always my weakest point in university, and so I never really tackled that part.  If you look at the code from Jarek's AVRsynth, he has some commented info about his DCF there.

Link to comment
Share on other sites

Michaël, it seems you hit a great point on every midiboxer's wishlist ;D

the second one seems like fourrier analyses/synthesis

I guess that would be a bit too much for the pic to handle in C 

Just noticed that I wanted to post this link:

http://www.geocities.com/tyala.geo/2ansynth.htm

so what I meant to share was:

if it's possible to add more oscillating (sine-)waves, you can create complex waveforms by simply playing these 4 osc's simultaneously in different pitches.

let's say we have a base frequency of 110 Hz, then we'd setup the harmonics:

f1 = 110 Hz, f2 = 220 Hz, f3 = 330 Hz, f4 = 440 Hz, f5 = 550 Hz, f6 ... (and so on...)

to create a complex square wave, the basic, 3rd, 5th and 7th harmonic with different volumes have to be played:

f1 (110 Hz @ 100% Vol)

f3 (330 Hz @ 33% Vol)

f5 (550 Hz @ 20% Vol)

f7 (770 Hz @ 15% Vol)

to create a saw waveform, it would look like this:

f1 (110 Hz @ 100%)

f2 (220 Hz @ 50%)

f3 (330 Hz @ 33%)

f4 (440 Hz @ 25%)

because of the static relations, it's quite easy to implement by lookup-tables.

If you're interested you can take a look in my speakJet code:

http://www.audiocommander.de/downloads/midibox/kII.tgz

Regarding your experienced approach I assume you already know this, but anyway... I hope you don't mind these notes... I'm really excited of the possiblities you opened up, mess! :D

Cheers,

Michael

Link to comment
Share on other sites

Here's v0.2 with pwm:

webs.hogent.be/~032573mh/coresound_v0_2.zip

I used a modified lfo source file from the analog toolbox for this

the lfo modulates the PWM amount

you can control:

initial pwm: cc#10

lfo rate:    cc#11

lfo on/off:  cc#12

note that this is pwm on the output square wave,

the output is still 1bit!

the next version will use a 8bit parallel dac (R2R of integrated) connected to PORTB

PWM output is good, as would be an 8-bit (or better) R2R ladder - forget about DACs, they're too pricey!

Right now I'm using a integrated dac so that I don't have to solder all of those R's

but I guess the R2R from AOUT_LC will do fine... I would connect it straight to PORTB, without the shiftregister

Doing a filter in software requires effort and knowledge of signal processing concepts.

I don't think it's possible to implement a filter with the current setup (non optimised C coding)

but it sure would be nice to have  :)

@ Michael

Nice work on the speakjet, I have found the frequency calculation part

The problem is that the pic has to calculate those 4 sinewaves and mix them together in software

wich would require a lot of multiplies...

Regarding your experienced approach I assume you already know this, but anyway... I hope you don't mind these notes...

All comments are welcome :-) 

the approach right now is actually quite simple:

increment a 16bit counter with a fixed frequency (2Mhz),

the size of the increment determines the frequency

take the top byte of the counter and...

output straight to dac: saw

use as index to a sine table: sinewave

compare against a value, if lower output 0 else output 255: square with variable pulse with

... and so on  :)

Link to comment
Share on other sites

I can't say I followed all the stuff in those last couple of posts, but it all seems pretty encouraging.

With regards to the PWM outputs, I used to have a SIEL mono which did something similar, basically adding the harmonics in different proportions. I think that had a really nice sound because it was not particularly accurate.

I'd be all over this project if it could perform as part of a modular system. That is, i'd want the core to output two sets of CV and gate triggers. One to trigger an analogue filter, and one for an envelope generator.

It's actually  a project that i've been wanting to develop for some time, but I don't have the skills necessary to code the cores to produce the actual waveforms.

Initially I thought that it would be cool to have a PIC based wavetable synth, but now I think it would be better to have a 'drawbar' type harmonics mixer, if that makes sense. That way you could mix in any number of odd and even harmonics and create new waveforms from scratch.

I'm inclined to want to keep this thing simple, so just having the oscillators in the digital domain would be enough for me. I'd happily make up any number of filters, envelope generators and so on from analogue circuits. Imagine, an MB DCO with the VCF & VCA from a MiniMoog ;)

Link to comment
Share on other sites

Well, I'm just working on the same project, but I use a AVR instead of a PIC. The way with PWM is nice and cheap. If you use a big Cap on the output, you can also use the pwm modulation amount as direct analog DAC output. Soundgin and Speakjet do it exactly that way.

I've bought some DACs (0832) for my project, but the hardware part get's bigger and bigger, because you also need some OpAmps and that is realy bad: negative voltage.

Link to comment
Share on other sites

Update:

-I've ported the filter code from the avrsynth to the pic,

the cutoff frequency can be adjusted manually or modulated with the lfo

-Three waveforms are available: sine, square(with pwm) and saw

-The lfo modulation amount can be controlled via cc

-Eg0 controlls the output amplitude

Most of this code was optimised in asm

The code is by no means finished or bugfree,

but it does generate sound  ;D

I'm using a 8 bit parallel dac right now, a mx 7228 from maxim (only one channel is used)

and after that a 2nd order sallen key lowpass filter to reduce aliasing noise

I still need to try out a pwm dac...

do I just need to configure the pwm unit and put my output value into the pwm register?

this way I could get rid off the external dac

also the accumulator should be modified for 24bits to increase the frequency resolution

right now the pitch is a bit off

@ MyCo

I know what you mean with the hardware part  :)

Have you tried using a virtual ground for the opamps?

I have reduced the dac output amplitude to 2,5v

together with an opamp powered from 0-5v with a 2,5v virtual ground

@ Jaicen:

You can always throw away the digital filter/modulation stuff if you don't need it  :)

Michaël

Link to comment
Share on other sites

-I've ported the filter code from the avrsynth to the pic,

the cutoff frequency can be adjusted manually or modulated with the lfo

-Three waveforms are available: sine, square(with pwm) and saw

-The lfo modulation amount can be controlled via cc

-Eg0 controlls the output amplitude

Well done!  I was trying to prototype everything in Labview first before I bothered with ASM, but got bogged down with the filter code.  I'm very glad to hear that someone has it working.

Are you reading the waveforms out of a table, or generating them on the fly?  If you are reading them out of a table, look for a few files on the web (or I could email them to you)... there's a "new.256" file that contains waveforms from a Wiard synth, and there's also the ROM from the Digisound's VCDO out there.  Both contain a number of interesting waveforms that you could use.  If you use a PIC with enough program memory, you could actually assign an LFO or ENV to sweep through various waveforms.

I'm using a 8 bit parallel dac right now, a mx 7228 from maxim (only one channel is used)

and after that a 2nd order sallen key lowpass filter to reduce aliasing noise

That's a great idea... in my original plan I was just going to leave the aliasing noise in there, but it can be a bit distracting.

also the accumulator should be modified for 24bits to increase the frequency resolution

right now the pitch is a bit off

Heh, I should've mentioned this earlier.  When I started on my project, I created a table of note values in Excel to determine the tuning error with various sizes of accumulator.  16 bits didn't cut it, but 24 bits worked great.

Again, great work, and keep it up!  It's fantastic to see people putting in the effort!

Link to comment
Share on other sites

  • 3 weeks later...

New version with 24 bit accumulator,

the software dcf and dca are disabled as I'm improving the resolution (to 16bit signed)

still struggling with the math  :(

right now you can play notes on channel one,

the output signal is gated so no envelopes and no velocity

when the dcf/dca works I will use the other dac outputs

to bring out the modulation signal's to control analog filters/vca's.

you can find the code here: http://webs.hogent.be/~032573mh/midibox/coresound/coresoundv0_5b.zip

the first schematic with the 8 bit DAC:

coresound.JPG

the dac is a MAX7228

connection to core:

[table]

[tr][td]coresound pin |[/td][td]core pin |[/td][td]pic pin nr[/td][/tr]

[tr][td]1 [/td][td]ground[/td][td] [/td][/tr]

[tr][td]2 [/td][td]J15:D7[/td][td]40[/td][/tr]

[tr][td]3 [/td][td]J15:D6[/td][td]39[/td][/tr]

[tr][td]4 [/td][td]J15:D5[/td][td]38[/td][/tr]

[tr][td]5 [/td][td]J15:D4[/td][td]37[/td][/tr]

[tr][td]6 [/td][td]J15:D3[/td][td]36[/td][/tr]

[tr][td]7 [/td][td]J15:D2[/td][td]35[/td][/tr]

[tr][td]8 [/td][td]J15:D1[/td][td]34[/td][/tr]

[tr][td]9 [/td][td]J15:D0[/td][td]33[/td][/tr]

[tr][td]10 [/td][td]J14[/td][td] [/td][/tr]

[tr][td]11 [/td][td]+5v[/td][td] [/td][/tr]

[/table]

disconnect any lcd from the core

also make sure that nothing is connected to J5

(I'm using those pins for debugging)

Michaël

Link to comment
Share on other sites

  • 2 weeks later...

*Update:

I've been working on a simple wavetable dco,

the biggest problem right now is finding (or generating) the actual wavetables...

for the first test I'm using wavetable bank0 of the wiard wavetable rom,

was has been converted to an asm include file using a perl script

here's a first wave example:

http://webs.hogent.be/~032573mh/midibox/coresound/crsnd_test1.mp3

*the modulation of the wavetable is done by incrementing/decrementing a counter on each note-on (no lfo's yet  :()

*since there are only 16 waveforms in a bank the dco interpolates between two waveforms to get 32 steps

*the 'envelope' is generated by smoothing the gate signal, the disadvantage is that there are still some pops

this will be solved once the EG works

@Myco:

How do the different dac's compare?

do you use a lowpass after the dac?

Michaël

Link to comment
Share on other sites

Your first example sound very nice. You are on a very good way :)

the biggest problem right now is finding (or generating) the actual wavetables...

Yep, i'm sure it's a big part. I think, (but it's just my opinion) that, the trick is to build a generator, better than store waveforms.

So you could have a function, with parameters like "wave (sin,saw,sqr)", volume (from,to), cutoff (from,to), resonance (from,to), phase (from,to), vertical shift (from,to), distortion (clip or wrap), so you can generate a big posibilities of waveforms on the fly with only few parameters to save.

[from,to] are the values you want to interpolate between the 16 steps.

More parameters : Speed,Length, Play(once/loop/pingpong)

Of course it's just a suggestion ;)

*since there are only 16 waveforms in a bank the dco interpolates between two waveforms to get 32 steps

16 Steps are allready GREAT !!! :)

It's very well done sir, i cant wait to have a synth like yours :)

Link to comment
Share on other sites

@bill:  generating waveforms in real time on a PIC is... well, challenging to say the least.  Especially if you want ones with rich harmonics and timbres in them.  There's a good reason that wavetables are used.

@mess:  glad to see that those wavetable files are coming in handy (assuming you got my PM, at least.  I haven't checked my website logs).  Good job interpolating between the waveforms in the table.  You should be able to double that 32 to 64 by adding an additional set of interpolations, but then it might be getting too processor-heavy for the PIC.  I'm not sure if you've had to start counting cycles yet :-)

Some of the waveform banks don't really "sweep" all that well.  But that data should be in the Wiard PDF I included, IIRC.  One possibility:  what if you didn't interpolate between the waveforms, but instead switched back-and-forth between the neighbouring waveforms.  For example, instead of interpolating to waveform 13.5, just alternate cycles of waveform 13 and 14.

Unsolicited feature suggestion:  you know, because at this point you really want people to start adding features to your design.  ;)  This one I think I stole from the Droid-3 synth.  As part of your filter, add a digital "drive" stage.  Essentially this is just a multiplier, except you can have a number of types of digital clipping.  (1) would be a hard limiter, clip at full + or - range. (2) would be a soft limiter, which requires some kind of light pseudo-compressor algorithm when you near max/min.  (3) would be an overflow distortion, ie a peak over +128 would overflow to -127.  (4) would be an inverse-peak distortion, that is to say, a value of +140 (ie, =128+12) would turn into +116 (=128-12).  I have no idea whether any of these would be sonically pleasing or not, though.  It's just something that I had been toying with in the back of my mind, and thought that I would throw out there, just in case you get bored  ;D

And as usual, good job, and keep up the good work!

Link to comment
Share on other sites

I have no idea whether any of these would be sonically pleasing or not, though

Well you should do some research into the effects of the harmonics it will create, it's quite interesting stuff. I'll save you some time and tell you now that they all sound very different and all have their place, but some will sound nicer, in a generic sense, than others :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...