hamster

Music box...

Recommended Posts

I've finally got my 'Synth' project to the point that it can act as an OK sounding music box:

http://www.hamsterwo.../Synth_Envelope

http://youtu.be/XRITkbgBR4c

It plays Brahms Lullaby in monophonic glory! One pair of switches changes between a Sine wave and a richer waveform I made in a spreadsheet. Other pairs control the envelope (Attack, decay and release rates). I'm thinking of using the ADC on the LogicStart to give me analogue control inputs...

It only 'does stuff' one clock cycle in 666 of the 32MHz clock, so there is plenty of scope to move to direct digital synthesis or massive polyphony.

Buried on the related pages are the C utilities to convert arrays to either 9 or 18 bit BRAM VHDL instances...

This post has been promoted to an article

Share this post


Link to post
Share on other sites

Hello Mike,

I am going to ask you to expose some of your secret :)

How did you manage to have the melody into a memory ? Did you extract it from a midi file ?

Thomas

Share this post


Link to post
Share on other sites

My secret is that I am useless at playing guitar, but did learn how to read music. :-)

It was hand transcribed from a page of sheet music found in Google.

If you want a tune, send me a link and I'll send you back some numbers.

Share this post


Link to post
Share on other sites

Just FYI that posted bit file doesn't work on the P1-500K as the name suggests. I grabbed the code from the link and noticed it's set in the .ucf to use the 250K. Changed that and was able to build it for the 500K no problem and it works. Neat!

 

Now to figure out how to make some different tunes.

Share this post


Link to post
Share on other sites

I was annoyed by the very long pause between looping the short melody so I added this (in bold):

 

process(clk32)
  begin
    if rising_edge(clk32) then
      if count = 666 then
          score_counter <= score_counter + 4;
           count         <= (others => '0');

              if score_counter = 8192000 then
               score_counter <= (others => '0');
              end if; 
 

 

All this does is reset score_counter when it reaches 8,192,000 rather than wait for it to hit 16,777,215 and wrap around. A much cleaner solution would be to place some sort of "end of tune" marker in the RAM that stores the melody and reset score_counter at that, but this was a quick and easy addition while I was playing with counters.

 

Now what we need is a brief tutorial on creating new melodies. It would also be cool to be able to connect some sort of input device to play notes manually.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now