Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / A little help with Sound...

Author
Message
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 10th Mar 2021 13:09
So, I've been hitting my head against a wall in regards to Generating Sound...
For the most part I have it working to a degree, but there are frustrating "Clicks" in the Generated Tones

I have a feeling that I need to add an Attack and Delay to the Generated Soundwave to stop this but I don't know... at this point I'm tired and have work in an hour or so.
If anyone else can have a crack at it to remove the "Clicks" / "Pops" that'd be great.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Mar 2021 13:49
only skimmed but reminded me of this thread which might help.
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
Ranietz
AGK Gold Backer
19
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 10th Mar 2021 16:27
Have you tried to save the sound as a .wav file and opening it in an audio editor like Audacity? That could give you some visual clues on what's going on.
I haven't played around with creating sounds from memblocks but what happens if you multiply the first byte of the memblock with 0.1 then the next one with 0.2 and so on until you get to 0.9? Would that create a very fast attack envelope?
And maybe do the same thing with the last bytes. Multiply the last byte with 0.1, then second to last with 0.2 and so on.
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 10th Mar 2021 23:30
All sounds need an amplitude envelope, no way around it. Any signal that doesn't start at 0 will click.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 11th Mar 2021 15:19 Edited at: 12th Mar 2021 06:31
Yeah, I don't think my issue is the Envelope... at least not specifically.
With 16b... sure adding an Attack / Delay will remove the Pop; and adding a full ADSR Envelope makes it as smooth as butter., rather the issue ends up being 8b.

So I decided to investigate further (now I have several cups of coffee in me, and a day off).
Turns out even a Blank Signal (i.e. no Soundwave, it should be silent) still produces popping with each sample... this makes me think the issue with 8b is with the AppGameKit Audio Engine and NOT my Sampling Approach.
As such, looks like I'll always have to use 16b... and have a flag to run an algorithm to mimic 8b output.

I'll post the results when I'm happy with it.

[edit]


Alright... I think it's in a "Happy" place for now., need to comment the actual CreateSound Function better... and there are a few functionality elements I want to improve.
Still, what I've got is a rather nice base for creating Chiptunes / Emulating "Old School" 8bit System Audio.

The Noise Function needs a bit of work to be used for Drums or such., but still it's a start.
Also replaced the Music, which required adding a "Tempo" Function along with changes to how the Notes are Formed (as it uses Accents to get the sound right)...
Have a play with it... what I want to do is create a Tool for actually writing Music Tracks and a Tracker / Midi Style Format; so the Music is generated "OnLoad"
I don't think AppGameKit is fast enough to do it "Real-Time" but maybe... have to see what I can work out.
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 13th Mar 2021 13:43 Edited at: 13th Mar 2021 13:45
Your first code snippet is generating a ton of DC offset. All the waveform is in the negatives so even with a signal of 0, you're not at 0. The first clue is that your sinewave doesn't sound like a sinewave at all.
DC Offset:


Not a sine:



Which you can solve by changing this line to remove the offset and put your waveform at true 0.


No DC offset:


True sine wave:


This will eliminate the click at the start of the sound since your wave now starts at true 0. It will not solve the end click as the length of your sounds is based on a set amount of time which means it can (and most likely will) not end on a 0. You can add a little fast fade out routine at the end to resolve this I guess.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 14th Mar 2021 08:00
Not sure if its any help but I found this very interesting (all his vids are very interesting)

there is a section on one of the videos that explain about wave shapes and clicking, maybe it can help your project,






The final project this guy turns out sounds amazing


Login to post a reply

Server time is: 2024-04-24 09:36:54
Your offset time is: 2024-04-24 09:36:54