The shoutbox is currently out of service. Join us on Discord instead.

Haskell Audio Synthesizer

Started by unknownloner, January 20, 2015, 06:56:03 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

unknownloner

I decided I wanted to learn the ins and outs of how audio actually works, and figured I could get some more experience with Haskell at the same time.
Anyhow, here's some code
https://github.com/unknownloner/HaskellSynth

And some sample output (though it's pretty easy to modify it to play something else)
http://z80.ukl.me/rfact.mp3

It's not exactly the most sophisticated synthesizer, but it's something, and is kinda neat to play with it.
I've got basic tones playing, but I want to create an Attack-Decay-Sustain-Release envelope so I can have proper notes. I also want to actually learn more about how sound works so I can create more interesting sounds, like some of the stuff you hear in more modern electronic music, because I still have no idea how :P
I also want to be able to read midi files, and handle the Note On/Note Off events to play an existing midi file.

  
/)

DJ Omnimaga

Oooh, old school sound there :D. You should keep it non-sophisticated :P. What would be cool is if it could produce both 8 bit and 16 bit chiptunes (maybe like the Sega Genesis)

Also reading midi files would be awesome. GXSCC does that but the drums are bad.

unknownloner

I might do some deeper research into the C64's SID and see if I can reproduce that sound, because I like what it can do.

  
/)

DJ Omnimaga

Yeah it would be amazing indeed. :D

Streetwalrus

Nice, a chiptunes synth. :D Looking forward to what you can do with it.

unknownloner

January 22, 2015, 02:38:41 am #5 Last Edit: January 22, 2015, 04:02:12 am by unknownloner
Well I may not be the best at composition, but this sounds kinda neat http://z80.ukl.me/test.mp3

EDIT:
Low-pass filter stuff:
http://z80.ukl.me/lfo.mp3

  
/)

DJ Omnimaga

Ooh I like that first one. It would fit well for a space game intro. :) Also interesting effects with the 2nd file :D

unknownloner

January 23, 2015, 02:53:02 am #7 Last Edit: January 23, 2015, 03:21:47 am by unknownloner
I keep using the same note sequences as I add more effects since I don't feel finding more, but it's a nice way to compare old vs new code
For example:
Here's a version of nightmare night from awhile ago when I just started: http://z80.ukl.me/nmn.mp3
Here's a new one with ADSR envelope (and some random values for it that I thought seemed alright): http://z80.ukl.me/nm.mp3
The synths aren't the same though so the style is a bit different.

Also here's a new rainbow factory, again with ADSR envelope
http://z80.ukl.me/rf.mp3

My file names keep getting shorter and shorter.

By the way if anyone has any sequences that might be fun to test with, let me know. As long as it's got sheet music (or a straight up list of notes), and a looping section that isn't too long, I might mess with it. (hint hint DJ_O ;))

EDIT:
lol bass
http://z80.ukl.me/bass.mp3

  
/)

Juju

Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

DJ Omnimaga

Quote from: unknownloner on January 23, 2015, 02:53:02 am
I keep using the same note sequences as I add more effects since I don't feel finding more, but it's a nice way to compare old vs new code
For example:
Here's a version of nightmare night from awhile ago when I just started: http://z80.ukl.me/nmn.mp3
Here's a new one with ADSR envelope (and some random values for it that I thought seemed alright): http://z80.ukl.me/nm.mp3
The synths aren't the same though so the style is a bit different.

Also here's a new rainbow factory, again with ADSR envelope
http://z80.ukl.me/rf.mp3

My file names keep getting shorter and shorter.

By the way if anyone has any sequences that might be fun to test with, let me know. As long as it's got sheet music (or a straight up list of notes), and a looping section that isn't too long, I might mess with it. (hint hint DJ_O ;))

EDIT:
lol bass
http://z80.ukl.me/bass.mp3
Unfortunately, I use an emulator so I cannot export note sequences for my songs, not to mention Music 2000 doesn't display note names so I am not very familiar with them.

Anyway your new examples sound nice. With ADSR values, are you able to make notes fade out, by the way? I noticed that you mostly use fade-in.

unknownloner


  
/)

DJ Omnimaga

Do you think some sort of reverb or echo like in some late NES games would be possible?

unknownloner


  
/)

DJ Omnimaga

January 24, 2015, 02:29:11 am #13 Last Edit: January 24, 2015, 02:31:56 am by DJ Omnimaga


Another example, although it's not a song, but rather a sound effect, is in Journey to Silius title screen when you press Start. Also the intro music has some echo effect it seems.


unknownloner

Not quite sure how this ended up working but kinda fun...
http://z80.ukl.me/notes.mp3

Sine wave with w/period of 0.9 * triangle wave w/period of 1.2 controlling notes

noteFor t = noteFreq (round (ctl t * 2) + 40)
    where ctl t = sineWave 0.9 t * triangleWave 1.2 t

  
/)

Powered by EzPortal