* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Haskell Audio Synthesizer  (Read 3793 times)

0 Members and 1 Guest are viewing this topic.

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Haskell Audio Synthesizer
« on: January 20, 2015, 06:56:03 am »
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.



  
/)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #1 on: January 20, 2015, 07:24:34 am »
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-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #2 on: January 20, 2015, 02:59:02 pm »
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.

  
/)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #3 on: January 21, 2015, 04:50:36 am »
Yeah it would be amazing indeed. :D
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #4 on: January 21, 2015, 02:47:10 pm »
Nice, a chiptunes synth. :D Looking forward to what you can do with it.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #5 on: January 22, 2015, 02:38:41 am »
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
« Last Edit: January 22, 2015, 04:02:12 am by unknownloner »

  
/)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #6 on: January 22, 2015, 04:17:59 am »
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-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #7 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
« Last Edit: January 23, 2015, 03:21:47 am by unknownloner »

  
/)

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2963
  • Post Rating Ratio: +27/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: Haskell Audio Synthesizer
« Reply #8 on: January 23, 2015, 05:07:32 am »
Ooh nice stuff here.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
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

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #9 on: January 24, 2015, 01:37:50 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.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #10 on: January 24, 2015, 01:38:48 am »
Yeah I can make them fade out.

  
/)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #11 on: January 24, 2015, 02:03:33 am »
Do you think some sort of reverb or echo like in some late NES games would be possible?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #12 on: January 24, 2015, 02:17:59 am »
Could you link some examples?

  
/)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18518
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #13 on: January 24, 2015, 02:29:11 am »


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.

« Last Edit: January 24, 2015, 02:31:56 am by DJ Omnimaga »
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline unknownloner

  • Full User
  • CW 4x3 challenge winner!
  • *
  • Join Date: Dec 2014
  • Location: Yesterday
  • Posts: 221
  • Post Rating Ratio: +1/-0
  • WHY CAN'T I CLICK ALL THESE CIRCLES?!
    • Code Blog
  • Gender: Male
Re: Haskell Audio Synthesizer
« Reply #14 on: January 25, 2015, 08:45:27 am »
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
Code: [Select]
noteFor t = noteFreq (round (ctl t * 2) + 40)
    where ctl t = sineWave 0.9 t * triangleWave 1.2 t

  
/)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games