Join us on Discord!
You can help CodeWalrus stay online by donating here.

Haskell Audio Synthesizer

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

Previous topic - Next topic

0 Members and 4 Guests 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)


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.

  
/)

Dream of 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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

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.

  
/)

Dream of Omnimaga

Yeah it would be amazing indeed. :D
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

novenary

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

unknownloner

#5
Well I may not be the best at composition, but this sounds kinda neat

EDIT:
Low-pass filter stuff:

  
/)

Dream of Omnimaga

Ooh I like that first one. It would fit well for a space game intro. :) Also interesting effects with the 2nd file :D
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

unknownloner

#7
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:
Here's a new one with ADSR envelope (and some random values for it that I thought seemed alright):
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


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

  
/)

Yuki

  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
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

Dream of 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:
Here's a new one with ADSR envelope (and some random values for it that I thought seemed alright):
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


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

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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

unknownloner


  
/)

Dream of Omnimaga

Do you think some sort of reverb or echo like in some late NES games would be possible?
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

unknownloner


  
/)

Dream of Omnimaga

#13


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.

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

unknownloner

Not quite sure how this ended up working but kinda fun...


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