SOUND freq, duration

DOS specific questions.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: SOUND freq, duration

Postby petan » May 07, 2013 13:45

Sweet, works on linux Slacko 533.
Thx,
Pete
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

Re: controling sound level

Postby DOS386 » Jun 15, 2013 6:24

opicard wrote:Please Is there any news since 2006 about it ?


Collection of PCI sound stuff: http://jafile.com/uploads/dos386/wssunjud.tar
Otter
Posts: 10
Joined: Nov 02, 2012 22:45

SOUND and PLAY implementation

Postby Otter » Sep 09, 2013 1:25

What was this mentioned library in the help of Basic 0.24? Anyway i didn't find it around and wrote the thing finally got the hands on it whew.

Here's it, use it who wants. The link to Media-fire = http://www.mediafire.com/view/3bgc2rbs9mxwbac/DYNAMEC.BAS
it's not a library now – just a file after #including it PLAY, SOUND in their nominal functionality can be invoked.
Also there's PLAYING that acts like PLAY(1) function, SNDFLOW to add a little more controls (check its comments).

To test it, the example musics program:
http://www.mediafire.com/view/4fjc8nmk1hfh6y4/MUSIQEU2.BAS
See there, there are more musics commented, if i have the incentive i'll bind them in too.

All the standard functions are done: foreground, background (using a parallel thread), ports, A. P. I., adjustable buffer,
in PLAY all ranges extended – it'll just play a pause if too low, and drop a token if something rong is in the string.. Underscores are added intermittent with points, to set length. API lets play from D of octave -1, and ports from D of octave -2.

It's not fully compatible: because PLAYING returns all time stretches as entries (normato notes' pauses are notes too), and MF waits right in THE sound, not before next sound, like it was..

THOUGH,,,, it sometimes hangs right away on the first OUT statement!! But if the first sound started, then it already won't hang this run. Maybe it's a Basic's mistake with OUT driver initiation or finalization? On Api it never hangs, and anyway, this hangout is rare.

I'd definitely want to complete this library – there are some functions that long longed to be added. Just now the field of unwritten tails holds me around. So this is the version 1.
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Re: SOUND freq, duration

Postby angros47 » Sep 09, 2013 10:25

Your library is windows only.
Other attempts have been made (CQBS, my fm sound), but unless a multi-platform solution is used, there is no way to implement sound commands.

The main issue is PLAY: in qbasic, it was too weak (even the version in MSX basic was better); even qbasic programmers used other solutions. So, the PLAY command should be improved (polyphony, many instruments, and so on); the best way would be to use MIDI, that seems perfect for that purpose: unfortunately, it's not a multiplatform solution (under windows, MIDI has a low quality, but is supported; under linux, it's not, unless you install timidity or something similar); many cross-platform midi solutions, like Allegro or SDL mixer, need to install a soundfont that can be really heavy (if you need to add a 50mb file of sound fonts, a MP3 would be a lighter solution than a MIDI); also, allegro and SDL mixer can only play standard midi files, they can't accept single midi events (and a PLAY implementation using MIDI would require sending an event for each note).

So... how to build a cross-platform PLAY solution? I have an idea... but I'd like to hear suggestions.
Otter
Posts: 10
Joined: Nov 02, 2012 22:45

Re: SOUND freq, duration

Postby Otter » Sep 09, 2013 17:35

(Yeah really, this is for Windows, but the theme seemed appropriate for the Play and Sound..)

A whole M. I. D. I. .... Well hehe, a complete music interface sure people have in mind but this is not striving for that – i wrote it just to have a compatible thing with QB, for programs that have been made to play on QB's methods. Or maybe for those who want it just for kicks of it. (maybe eventally i'll upload some examples of cartoons that used that, and didn't need more)

Yeah, it is no way intended to be a "real" music thing. I can't write for Linux and Dos at the time being, but why can't just the internal speaker be wrapped and added to FB? Ports 61 and 43, are everywhere.

And the whole interface, sure before making any music, first of all FB should have a unified sound interface. Unified, i mean 1 command SCREEN 12 and you have graphics; 1 command – and you have sound. Now yet it doesn't - there are a plenty of libraries, but they have to be programmed by copying examples: it's unknown, what exactly to use.... Such diversifiedness usually don't work without further consultation. I personally would like to help on making a unified sound through soundcard, to mix WAVs at least, (then decode something), but i even couldn't yet wrench any sound, other than Future library's "Loadwav"☺.

As a side note, heh, i have a mate who's kind of a musician, and after years of trying different interfaces (game music makage in mind) he fell to conclusion that it's easier to take an instrument and play it live – all are unappropriately tangled.

All in all, i thought these were 2 separate tasks.
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Re: SOUND freq, duration

Postby angros47 » Sep 09, 2013 19:25

Otter wrote:i wrote it just to have a compatible thing with QB, for programs that have been made to play on QB's methods. Or maybe for those who want it just for kicks of it. (maybe eventally i'll upload some examples of cartoons that used that, and didn't need more)


The only issue is... qb sound is awful! Qb64 tries to emulate it, using a square wave... but it's just for porting old sources from qbasic.


Yeah, it is no way intended to be a "real" music thing. I can't write for Linux and Dos at the time being, but why can't just the internal speaker be wrapped and added to FB? Ports 61 and 43, are everywhere.


We can, and we did:
http://www.freebasic.net/forum/viewtopic.php?p=108677#p108677

using pc speaker for play and sound would provide an audio output that is 100% the same of qb audio.

But FreeBasic should be able to do something better... FB graphic features are far better than QB, although syntax is similar; why not doing the same for sound? A polyphonic PLAY command, a more versatile SOUND command, the ability to work on sound buffers...


And the whole interface, sure before making any music, first of all FB should have a unified sound interface.


There is no "official" one... but FBSound by D.J. Peters is becoming the standard de facto.

Anyway, in my opinion FBSound is not in line with "basic" spirit: it can load many sound formats, but it doesn't provide tools to create new ones: it's like having a graphic library that can load .jpg, .png and many other files, but lacks commands like LINE, CIRCLE and so on. Actually, you could create new sounds with FBSound by accessing raw data... but it's nothing more than being able to access an image pointer, and accessing pixel data.



Unified, i mean 1 command SCREEN 12 and you have graphics; 1 command – and you have sound. Now yet it doesn't - there are a plenty of libraries, but they have to be programmed by copying examples: it's unknown, what exactly to use.... Such diversifiedness usually don't work without further consultation. I personally would like to help on making a unified sound through soundcard, to mix WAVs at least, (then decode something), but i even couldn't yet wrench any sound, other than Future library's "Loadwav"☺.


My "ideal" sound library should support only .wav files (as graphic library supports only .bmp); if you want other formats, you can use external loaders. But it should provide tools for simple sound synthesis: a wave generator (sine,pulse, sawtooth, triangle), an envelope generator, frequency modulation, amplitude modulation, high and low pass filters.... that kind of stuff.

It's not easy, but should be doable.
Otter
Posts: 10
Joined: Nov 02, 2012 22:45

Re: SOUND freq, duration

Postby Otter » Sep 15, 2013 21:56

Checked them all out.

That's a pity every1 goes straight to the alternatives, without actually having compatible speaker subprograms. F. M. Q. B. S. also plays the speaker only on D. O. S., doesn't it? And only if there's no audiochip (by the way it hangs – just now tested on DosboX).
....Quick Basic 64, C. Q. B. S. and DosboX, all use the audiocard – but it's worse than the speaker itself when making such notes (not to mention they are all buggy and stuttering). It's like, to only prove that we don't want to listen to mono-channel. But if a program happened to actually please its listeners, they won't be satisfied with the audiocard rimplementation.

But here anyway, i just must finish that library, which is in coarse state too.


As to the whole,
In the infinite space of fully digitized sound (no poetry intended), any single "notes" would seem not satisfying. No VSTs of SF2-s or Windows MIDI can do something *definite* – you always float around with hundreds of handles to pull. Really, why can't we deform this sample like that, or take this instrument instead, and anything like. Thus, no basic creativity tool. Instructing notes was feeling enthusiastic only when you have a finite instrument, that can do only these notes. Hardware synthesizers (and that puny speaker included) were suited better for it.

Surely sure, i also want something as a creation tool on current soundchips. But it has to be, maybe, a *harmonic* structure, not *atomic*, to compose music. Like superposing gammas together, instead of stacking notes 1 by 1. But that's very experimental, and would end up as a program itself, not a library.
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Re: SOUND freq, duration

Postby angros47 » Sep 16, 2013 19:13

FM version requires OPL2/OPL3 chip, integrated in adlib and soundblaster cards (in modern sound cards, it's not available, but dosbox emulates it); anyway, it can be emulated with adlibemu in freebasic (the advantage is: multiple instruments will be available, and the result will sound identical in every operating system); since, in Freebasic, graphic library emulates vga fonts to provide, in graphic windows, a DOS- like text, why a sound library shouldn't emulate sound blaster to provide DOS-like sounds?

CQBS and QB64 just emulate the pc speaker, and the result is awful (a simple square wave)

About your idea of "harmonic" synth... you remind me of ZynAddSubFX and PADSynth.
Otter
Posts: 10
Joined: Nov 02, 2012 22:45

Re: SOUND freq, duration

Postby Otter » Sep 24, 2013 4:21

graphic library emulates vga fonts to provide a DOS-like text, why a sound library shouldn't emulate sound blaster?

We got wrong direction – i, really, would only like it, if a language had everything readily, no argument, but just guessed until every1 makes their minds to coincide on a single suitable sound interface, the speaker support could already be done.

And graphics, it's not just DOSlike – it's QB-like fonts, readily built-in then, that many projects may already rely upon for their result. And audiocard in QB was another thing. Then again, every1 only experimented with it.

Then
CQBS and QB64 just emulate the pc speaker
, no, that's it – they produce essentially a new signal. It sounds different from the hardware x86 built-in case speaker, that's what i mean. Even if it's by definition a same, square wave. Maybe i happened to have speakers sounding "good" among their class, but sure CQBS and QB64 sound much much worse. (and much more is D. O. S. box, really awful), that's, yeah, truth.
Maybe, like, some spk-s had a scintillating timbre (and some cases still have it now, he_he) and software imitations are only dragging up to the specifications, kind of.
Just, the sound was agreeable to ears. If not to be called musical, then "funny" at worst. Didn't ya hear such spks?

--

ZynAddSubFX, PADSynth, will getta see'em.
--

And also i made it out DYNAMEC.BAS hangs the ports not because of driver, maybe because there are phase transitions that must be done carefully. All examples state only 3 commands to on the port, and 1 command to off it. But to go between notes without a click, and start from a pause, and so on, they must be tinked with. Even Intel printed that OUT 61, 00000011 shouldn't be used to start a note.
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Re: SOUND freq, duration

Postby angros47 » Sep 24, 2013 4:44

This is my attempt to implement "play" through adlib emulation: the sound resembles many dos games, and imho is much better than the one you can get with the speaker.

http://www.freebasic.net/forum/viewtopic.php?f=8&t=21623

Of course, it's not perfect... but it's lightweight, and cross platform.
RockTheSchock
Posts: 220
Joined: Mar 12, 2006 16:25

Re: SOUND freq, duration

Postby RockTheSchock » Sep 27, 2013 8:05

Perhaps an OPL3 / OPL2 emulator like this one could be a good base:
http://opl3.cozendey.com/
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Re: SOUND freq, duration

Postby angros47 » Sep 27, 2013 9:24

The applet crashes on my computer. Anyway, my demo already contains an emulator (adlibemu, written by Ken Silverman): it's written in C, so it can be included in a freebasic program without any external shared library. Your version, in Java, is not so easy to integrate with freebasic.

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest