Skip to main content
Topic: Music Box / Wavetable Synthesizer / DDS (Read 37325 times) previous topic - next topic

Re: Music Box / Wavetable Synthesizer / DDS

Reply #15
Fine :)  Have fun!

Re: Music Box / Wavetable Synthesizer / DDS

Reply #16
I've understood how to use python script. I've modified it to put values on a file instead of the screen by adding
Code: [Select]
print >>fout 
where fout is a file pointer. With some midi is also useful to reduce the note duration by dividing time, example:
Code: [Select]
print >>fout, '    %s, %s,' % ( int( time )/3, int( pitch ) )
in this case I've reduced 3 times the note duration and the attached tune "Beethoven - For Elisa" sounds good. I've attached the tune and modified script. It would be great to load tunes from a thumbdrive.

[attachment=0]

[attachment=1]

Re: Music Box / Wavetable Synthesizer / DDS

Reply #17
Nicely done

Re: Music Box / Wavetable Synthesizer / DDS

Reply #18
Nice job!  Those speakers sound pretty good for cheapies, how do they sound with normal music?

Re: Music Box / Wavetable Synthesizer / DDS

Reply #19
Hello.

I find this project very interesting but I have a few questions. I've not looked at the code in detail yet but am planning to shortly. My questions are:

1. Are the waveforms in the wave tables sin waves? It doesn't sound like it. Are they square waves? If not what?

2. Are the envelopes applied when the midi files are processed or in real time during playback.

3. What are the envelope parameters: attack time?, decay time?

4. Are the envelope parameters the same for all notes?

Thanks for a great project

Re: Music Box / Wavetable Synthesizer / DDS

Reply #20
Great project. The music box sound is excellent!

I was curious what the waveform and envelope looked like, so I plotted them...

This is the waveform. The last cycle is repeated for sustain.
[attachment=1]

This is the envelope. I wonder if this was calculated or derived from a sample.
[attachment=0]

Re: Music Box / Wavetable Synthesizer / DDS

Reply #21
The single sustain cycle is a calculated sinus wave.  The sample count was chosen so that no amplitude step is skipped: sample_rate / ( 256 * math.pi )

The attack waveform was taken from Chan's code and resampled to match the fundamental frequency of the calculated sine wave.

The envelope was also calculated using a decaying exponential function.  The time constant was chosen just to fill 1024 bytes, since single amplitude steps at the beginning would have led to too much bytes to reach 0, and they cannot be heared anyways.

All the details for generating the data can be found in the 'dds' folder.  The file 'dds.py' is your friend.

Have fun,
Markus

Re: Music Box / Wavetable Synthesizer / DDS

Reply #22
Wow...!!! Sound is really nice there!!!

First off,sorry for my bad english,I'll try my best...

-Even I'm a loooong time background DP reader,I've just registered over here to let you know How much IMPRESSED you left me with the =Really Good Quality Sound of your Synth=.

Thank you very much for posting!!!

Re: Music Box / Wavetable Synthesizer / DDS

Reply #23
Would it be too difficult,instead of playing a melody,play some musical notes? p.e-nine musical notes...for a homemade e-drum or a keyboard...That would be Great if we can change the notes for different instruments!


Un Saludo...

Re: Music Box / Wavetable Synthesizer / DDS

Reply #24
[quote author="Markus Gritsch"]The single sustain cycle is a calculated sinus wave.  The sample count was chosen so that no amplitude step is skipped: sample_rate / ( 256 * math.pi )

The attack waveform was taken from Chan's code and resampled to match the fundamental frequency of the calculated sine wave.

The envelope was also calculated using a decaying exponential function.  The time constant was chosen just to fill 1024 bytes, since single amplitude steps at the beginning would have led to too much bytes to reach 0, and they cannot be heared anyways.[/quote]
I wonder if you could improve upon the original. It seems that you might have already made some changes. My first impression was that the sustain seems different than a mechanical music box, and I guessed that maybe the decay was linear rather than exponential. But, you can it's exponential, so maybe it just seems that the decay lasts too long. I searched for some recordings of vintage music boxes, and I think the decay is faster. Then again, maybe there are a wide variety of sounds out there.

Great work! I'm just making suggestions in case you want to fine tune this thing.

Re: Music Box / Wavetable Synthesizer / DDS

Reply #25
In nature, virtually nothing decays linearly.  Most things degrade to an exponential rate.  Maybe the time constant of the exponential decay of a real music box is shorter, but then as you said, there are probably many different sounding music boxes out there, and mine has per definition a low damping factor ;)

Re: Music Box / Wavetable Synthesizer / DDS

Reply #26
Ah, I should have said that I thought the virtual music box might have sounded strange because it had a linear decay. I know that our ear's response to sound intensity is not linear.

Would it be possible to make the decay variable?

Re: Music Box / Wavetable Synthesizer / DDS

Reply #27
Sure. The envelope table is precalculated, so just change the time constant in line 1939 of dds.py.

Re: Music Box / Wavetable Synthesizer / DDS

Reply #28
I searched for some random music box videos on YouTube, and IMO some of them have a relatively long sustain period.  For example if you listen to this one http://www.youtube.com/watch?v=OiRvvJjzXs4 at position 0:30, you can hear about 4 seconds of sustain -- about the same time I choose in my code.

I agree, that such a long sustain time creates a bit of a "smeared" sound.  I have attached two versions of "Linus & Lucy" played with my music box code, one with the long sustain setting (dds_env7.mp3), and one with a shorter one (dds_env6.mp3).  The files are zipped because .mp3 is not allowed as an extension by this board.  The bitrate is also only 64 kbit/s to get below the maximum file size of 1 MB.  Enjoy :)

Re: Music Box / Wavetable Synthesizer / DDS

Reply #29
I don't know if it's relevant, but the music box only has one "oscillator" per pitch, so if a specific note starts again while it is still sustained, then the existing sound should be replaced/restarted. I haven't looked at your code to see whether you're accounting for this, but it might affect the accuracy of the sound in a subtle way.