Forum Discussion
11 Replies
- Altera_Forum
Honored Contributor
As the link you included suggests you need to create ROM images, one for each tune you wish to play, containing all the samples and timing required by each tune. Your logic will then, based on a key press, replay the chosen samples (from the appropriate ROM) to the DAC on the DE1. You may well need to cascade a number of M4K memory blocks for the longer tunes.
- Altera_Forum
Honored Contributor
thanks a_x_h_75 for ur feedback. hmm my problem is i dont know how to create rom files. i have seen this code from this site utilizing only some codes I can understand. this is in russian http://marsohod.org/index.php/projects/6-playmusic http://marsohod.org/index.php/play-pmv . can i implement this in the DE1 board? please help me i am new to this. many thanks.
- Altera_Forum
Honored Contributor
I post a vhdl implementation of a rom. It's a non synchronous rom, so it behaves like a combinational circuit.
- Altera_Forum
Honored Contributor
bertulus. thanks for the file! :-) now my problem is how i can relate the musical notes of Rudolf song to the verilog code. the beat of the notes e.g. quarter, half note and the tune of the notes of the song e.g. do ,re mi...
- Altera_Forum
Honored Contributor
The fpga4fun design uses a pwm signal to generate the tones. Each tone has frequency ( or period ) and a duration. You may write 2 roms, one for the period of each tone and the other for the lenght ( in pwm periods ) of the note. You read at same time both tables and get the all the information need to play this note. When finishes you increment a register and read the next value on table until end.
- Altera_Forum
Honored Contributor
oh. so you mean that the music.mif file is the one that dictates the notes of the song, e..g. do la fa mi re sol la...
- Altera_Forum
Honored Contributor
Yes. You get the notes from 2 tables.
- Altera_Forum
Honored Contributor
Many thanks! However im not sure what is the corresponding note the address and register are pertaining? If you could elaborate further. i have attached the screenshot of the .mif file. thank u
https://www.alteraforum.com/forum/attachment.php?attachmentid=7926 - Altera_Forum
Honored Contributor
Regarding to the rom contents, for example if the 1st note is la ( 440Hz ) and system clock is 50MHz, you may store as first value in the rom table:
50MHz/440Hz = 113636 It's a huge value, you'll need many bits. You may slow down 50MHz so you get a smaller divisor number. If you generate a tick of 1MHz this divisor factor is: 1MHz/440Hz = 2273 ( this will be the first value on rom table ). In the second table you store the duration. For example, if the note lenght is 250ms and the note period: 1/440Hz=2,27ms The duration is 110 clock periods ( you put this as first value in the duration's table ). And so on. - Altera_Forum
Honored Contributor
Alright, I'll chime (horrible pun!) in.
Have you considered a microcontroller? Not that I'm particularly partial to them but I've seen a couple of questions on this forum that would be much easier solved if you'd go with an AVR or PIC. Just think that for certain problems an FPGA is overkill :-) -Mux