flat assembler
Message board for the users of flat assembler.

flat assembler > Examples and Tutorials > Crazy development: 1. Drawing waveform with plain FASM


What do you think?
It’s crazy
50%
 50%  [ 2 ]
I do such things all the time
50%
 50%  [ 2 ]
Total Votes : 4

Author
Thread Post new topic Reply to topic
DimonSoft



Joined: 03 Mar 2010
Posts: 451
Location: Belarus
One of my students is currently writing an audio editor in C and WinAPI as his course project. He obviously has some difficulties understanding certain concepts, so it takes some time. I felt bored and decided to write one of the main pieces from the users’ perspective, i.e. drawing waveforms, in plain FASM.

The source code from the attachment actually produces a 24-bit BMP image containing a waveform for the specified 16-bit signed PCM WAVE file. Everything is done at compile time.

Since I’m obviously abusing FASM’s features the process is quite slow (and I didn’t bother to optimize it). It took me about 20 seconds to draw waveform for a 1 minute WAVE file, but there’s a SkipFactor parameter that lets you tell the “program” to only use every Nth sample in its calculations. Having its value around 32 or 64 allowed me to decrease the compile time for 1 minute WAVE file to about 6 seconds.

All the parameters are at the top of the source, namely:
* SourceFile is… path to the source WAVE file
* Width is the width of the image to be drawn
* Height is the height of the image to be drawn
* SkipFactor is for performance vs precision tweaking.

Might be useful for some crazy guys out there who want to understand some FASM features along with WAVE and BMP formats.


Description: Crazy development: 1. Drawing waveform with plain FASM
Download
Filename: DrawAudio.asm
Filesize: 3.81 KB
Downloaded: 81 Time(s)

Post 10 Oct 2018, 23:38
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16128
Location: Hyperborea
I want to vote for both options.
Post 11 Oct 2018, 02:02
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1257
Location: In a West End town
Wow Smile

Can't wait for: Crazy development 2
Post 11 Oct 2018, 05:20
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6999
Location: Kraków, Poland
revolution wrote:
I want to vote for both options.

Definitely both. It is obviously crazy, but it also follows in line of many other similarly insane applications of fasm that were posted here over the years. For example that TGA file with generated image of Mandelbrot set, later extended with compression to GIF. Or a sound file made in the same thread.
Post 11 Oct 2018, 10:44
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 451
Location: Belarus
Having some control over the window that shows up while the compilation is in progress might make things a bit better for “users” of such FASM applications. I personally lack two things:
* equivalent of display directive that would allow setting some line of text to be shown in the window;
* some directive that would allow to set the position of the progress bar.

As for the second, maybe it’s only my experience but in my case it either shows up for a tiny period of time and immediately disappears or, in the case of this code, hangs there for half a minute with the same position of the progress bar. Giving more control to the code being assembled might have improved the situation in cases authors can provide useful information and care about doing so.
Post 11 Oct 2018, 16:15
View user's profile Send private message Visit poster's website Reply with quote
idle



Joined: 06 Jan 2011
Posts: 356
Location: ukraina
i wonder how reversive img2wav would look
Post 11 Oct 2018, 16:18
View user's profile Send private message Send e-mail Reply with quote
idle



Joined: 06 Jan 2011
Posts: 356
Location: ukraina
DimonSoft the very student of TG, ex me for offtop?
Post 11 Oct 2018, 16:24
View user's profile Send private message Send e-mail Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 451
Location: Belarus
idle wrote:
DimonSoft the very student of TG, ex me for offtop?

Sorry, don’t get what you ask about. What do you abbreviate as TG?
Post 11 Oct 2018, 19:19
View user's profile Send private message Visit poster's website Reply with quote
idle



Joined: 06 Jan 2011
Posts: 356
Location: ukraina
Tomasz Grysztar
Post 12 Oct 2018, 08:00
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6999
Location: Kraków, Poland
DimonSoft wrote:
Having some control over the window that shows up while the compilation is in progress might make things a bit better for “users” of such FASM applications. I personally lack two things:
* equivalent of display directive that would allow setting some line of text to be shown in the window;
* some directive that would allow to set the position of the progress bar.
Perhaps something like the -v2 switch that fasmg has? It could be a trivial addition for the console fasm, but making it work with the GUI would require more work.
Post 12 Oct 2018, 08:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.