Can someone explain this?
Mailing lists / fpc-pascal / 2010-06
Bug?
33 messages · 15 people · –
- GGraeme Geldenhuys 8
- HHenry Vermaak 5
- Ddmitry boyarintsev 4
- AAlexander Grau 3
- MMarco van de Voort 2
- RRoger Bailey 2
- +9 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Roger Bailey wrote 16 lines
The addition of () actually calls the function.
> TestFunction := ActualParameter ; { gives "incompatible type" error, but ... }
Here you try to assign the ActualParameter (a function pointer) to the result (an integer). This of course gives a type error.
> TestFunction := NamedFunction ; { ... compiles and runs o.k. }
This is simply a regular function call.
Michael.
Can someone explain this?
Roger Bailey wroteCan someone explain this?
You are using FPC mode rather than TP or Delphi mode. Add {$mode tp} or {$mode delphi}, or compile with -Mtp or -Mdelphi
Jonas
Hi,
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a cross-platform API or FCL class for this?
If so, what sound format's are supported? ogg, wav, mp3?
Graeme Geldenhuys wroteHi, Has anybody managed to play sound files under both Linux and Windows? Does FPC have a cross-platform API or FCL class for this?
fpc has bindings for libsndfile, which according to the website can read/write wav and ogg, among others.
Henry
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Show quoted text 8 lines
We have developed some kind of API to play a .wav file on both Windows and Mac. The Windows version is easy (below), the Mac version is long (400 lines).
If someone would like to add a PlaySoundFile API to LCL/FPC, drop me a note and we will donate the Mac code for it :-) ...
Regards,
Alexander
uses windows, mmsystem;
procedure PlaySoundFile(filename: string);
begin
PlaySound(pchar(filename), 0, SND_FILENAME + SND_ASYNC);
end;Alexander Grau wroteIf someone would like to add a PlaySoundFile API to LCL/FPC, drop me a note and we will donate the Mac code for it :-) ...
Thanks for that. A quick test removing the SND_ASYNC option plays multiple sound files in quick succession - just what I wanted. I'll experiment with libsndfile tomorrow, to see if I can accomplish the same under Linux.
As long as I can find out the various options for each platform, I can very easily put together my own sound playing API/Class, so that is not much of a problem.
Graeme Geldenhuys wrote 9 lines
Note that the fpc libsndfile example is outdated (it uses oss). There is an example in the libsndfile source for how to play this with alsa. If you're not worried about gpl, then I'd probably use libao.
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Hi Graeme
Graeme Geldenhuys wroteHi, Has anybody managed to play sound files under both Linux and Windows? Does FPC have a cross-platform API or FCL class for this?
UltraStarDeluxe uses ffmpeg for decoding and portaudio, a C library, for playback of the stream. Corresponding headers are here:
http://ultrastardx.svn.sourceforge.net/viewvc/ultrastardx/trunk/src/lib/
If so, what sound format's are supported? ogg, wav, mp3?
yes, and probably even more.
Regards, - Graeme -
Greetings - Michael.
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Has anybody managed to play sound files under both Linux and Windows?
One more option I know of is Audorra (http://audorra.sourceforge.net/). I have not used it though, so no idea about its advantages/drawbacks.
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Graeme Geldenhuys wroteHas anybody managed to play sound files under both Linux and Windows? Does FPC have a cross-platform API or FCL class for this?
I'd offer using OpenAL, however it requires proper libraries to be installed on Linux (afaik installed by default in all modern desktop distribs), and proper .dlls available for Windows.
There's proper example in FCL how to use OpenAL to play .wav, .ogg .mp3 files.
thanks,
dmitry
dmitry boyarintsev wrote:
Graeme Geldenhuys wrote 8 lines
I second that, AL is worth considering. It was very easy for me to use, at least once I found a decent WAV loader.
I have a little "OpenAL kit" for the Mac here:
http://www.ragnemalm.se/lightweight/openal_fpc.zip
On the Mac it it great: always installed, much better API than Core Audio, and portable. Havn't tried it on Linux och Windows though. And there is one problem that AL doesn't help me with (apart from loading WAV) and that is to play music. Uncompressed sound isn't useful for music. I can play that with Quicktime, but I'd like to use something cross-platform.
/Ingemar
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
[I don't know if a previous email of similar content got through. Sorry if this is a double post.]
As libsndfile has already been recommended, I would just add that the simplest and most fool-proof way of playing back audio (once you have figured out how to load it) is PortAudio. It abstracts away from WDM, ASIO, ALSA, Jack, CoreAudio and what not. It is in my view much easier to use than OpenAL.
Up-to-date PortAudio 1.9 bindings for FPC can be obtained here (not tested on MacOS):
http://sourceforge.net/projects/humus/files/
Note that UltraStarDeluxe (mentioned in another reply) seems to have bindings for PA 1.7, which is outdated. It also does not provide the platform-specific extensions.
Cheers!
Roland
Graeme Geldenhuys wrote 7 lines
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
In our previous episode, Graeme Geldenhuys said:
Show quoted text 5 lines
KDE's phonon also has OS X and Windows packages:
Sorry, I committed the cardinal sin of getting the subject line wrong. Corrected now :-)
Michael Van Canneyt wrote 20 lines
Sorry. I guess your explanation states what the compiler is doing, so in that sense your reply isn't "simply" wrong. However, the program fragment "TestFunction := ActualParameter" is a syntactically correct function call as as defined by the LRG, so the statement "Here you try to assign the ActualParameter (a function pointer) to the result (an integer)" is wrong. In fact I now notice you you give an almost identical example in the LRG (page 96)Show quoted text 15 lines
It's clear from this that the meaning of "Addone" depends on the context, here the type of the variable on LHS of the assigment. On this basis I think that the error message I received is either a compiler bug, or FPC implements a slightly perverse dialect of Pascal (so the LRG is wrong).
Hope this helps,
Roger Bailey
Note that the fpc libsndfile example is outdated (it uses oss). There is an example in…
Op 2010-06-14 17:31, Henry Vermaak het geskryf:
Note that the fpc libsndfile example is outdated (it uses oss). There
Outdated is correct. The version in FPC 2.4.1 doesn't currently compile, and references data structures not defined in the libsndfile unit.
I have a ESD (Esound daemon) header conversion that plays a single file perfect on multiple linux distro's, but when I try and play multiple files in succession, it plays all of them at the same time and doesn't wait for one to complete before starting the next. There doesn't seem much help on libesd either, but I'll take another look today. :-(
If you're not worried about gpl, then I'd probably use libao.
As long as it is very simple to deploy, or better, included with most linux distros, then it's better.
My sound requirements is not very high. As long as I can play wav, ogg or mp3 (any format will do really, but mp3 is not standard with Linux) and play one file after the other without delays. I have random sound clips that together make up a English or Afrikaans sentence.
Regards,
- Graeme -
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Op 2010-06-14 15:37, Graeme Geldenhuys het geskryf:
Has anybody managed to play sound files under both Linux and Windows?
Thanks for everybody's responses. I'll work my way through all of them today. Now I understand all the comments on the net about the state of audio (and gaming) on Linux. It's a damn mess with 1000's of options and each one in a different state of development or functionality.
Has anybody tried SDL (Simple-Direct-Media)? I know SDL Graphics works well with Free Pascal, but not sure about the Audio part.
Regards,
- Graeme -
Graeme Geldenhuys wroteOp 2010-06-14 15:37, Graeme Geldenhuys het geskryf: Has anybody tried SDL (Simple-Direct-Media)? I know SDL Graphics works well with Free Pascal, but not sure about the Audio part.
Audio works just fine. You can use SDL_Mixer library (though it has its own glitches).
thanks,
dmitry
Thanks for that. A quick test removing the SND_ASYNC option plays multiple sound files in…
Show quoted text 16 lines
For Linux, I think it can be simple as opening a file and writing the raw audio data to it - using a simple WAV header reader or even an MP3 decoder for FPC, it should be possible to directly use the sound device (/dev/dsp):
http://www.opensound.com/pguide/audio.html
This is not the most elegant (or easiest) solution, however it has no dependencies to any libraries :)
I think for getting a simple playSoundFile() API to FPC/LCL on all platforms, dependencies to 3rd-party libs can be avoided.
Regards,
Alexander
Alexander Grau wroteThis is not the most elegant (or easiest) solution, however it has no dependencies to any libraries :)
The solution still depends upon decompression libraries. However, they can be statically linked.
thanks,
dmitry
Show quoted text 9 lines
Yes, correct - I was assuming that uncompressed WAV files are being used
- For compressed audio data, there might exist decompressors and decoders for FPC already ... or at least Delphi code for it :-)
Show quoted text 7 lines
Op 2010-06-14 15:37, Graeme Geldenhuys het geskryf: Thanks for everybody's responses.…
Graeme Geldenhuys wrote 8 lines
You'll probably find that there's 1000's of sound libraries for windows, too. There are different concepts here: sound architecture in the kernel (alsa, oss (deprecated)), sound daemons (pulseaudio, jack, arts, esd), file format reading/writing and decoding of codecs (mp3, ogg, etc). On top of these you get the libraries that try and make this cross platform.
You can do _very_ cool things with audio on linux. I've got a friend that runs a recording studio on ubuntu :)
Henry
For Linux, I think it can be simple as opening a file and writing the raw audio data to…
Alexander Grau wroteFor Linux, I think it can be simple as opening a file and writing the raw audio data to it - using a simple WAV header reader or even an MP3 decoder for FPC, it should be possible to directly use the sound device (/dev/dsp):
Note that OSS is deprecated, so this solution won't last very long.
I think for getting a simple playSoundFile() API to FPC/LCL on all platforms, dependencies to 3rd-party libs can be avoided.
If you want you program to be a good desktop citizen, you should talk directly to the sound daemon (pulse on gnome, phonon on kde?).
Henry
In our previous episode, Henry Vermaak said:
Show quoted text 6 lines
The fact that they are different is the main problem there.
Note that OSS is deprecated, so this solution won't last very long. If you want you…
Henry Vermaak wrote 10 lines
True. I've written my last OSS-only application a year ago and it didn't work on over 50% of computers I've tried it on.
Now I use Alsa or Jack. Jack is very simple to use and very powerfull, but not available everywhere. Alsa is everywhere.
In our previous episode, Henry Vermaak said: The fact that they are different is the main…
Marco van de Voort wrote 9 lines
Yes, it makes it harder. Just like gtk vs qt.
One more option I know of is Audorra (http://audorra.sourceforge.net/). I have not used…
Op 2010-06-14 18:26, Vladimir Zhirov het geskryf:
One more option I know of is Audorra (http://audorra.sourceforge.net/). I have not used it though, so no idea about its advantages/drawbacks.
Some feedback for general FPC users thinking of using Audorra. It's 32-bit only and after some hacking (removing libc unit and cinerella dependencies) I got it compiled under 64-bit Linux. Unfortunately being able to compile it doesn't mean much. The LCL demo out-of-the-box experience is not very nice. I'll try and create a "audio-only" console demo to see how that goes.
Regards,
- Graeme -
Has anybody managed to play sound files under both Linux and Windows? Does FPC have a…
Some more feedback. I found ACS in Lazarus wiki sight and in Lazarus-CCR subversion repository. This is very old and outdated. It requires libc (kylix compatibility) unit and is x86 and 32-bit only. It has some ASM code in there (yuck!). So this was a non-starter for me.
Regards,
- Graeme -
On Mon, Jun 14, 2010 at 5:37 PM, Graeme Geldenhuys I'd offer using OpenAL, however it…
Op 2010-06-14 18:28, dmitry boyarintsev het geskryf:
There's proper example in FCL how to use OpenAL to play .wav, .ogg .mp3 files.
I can't find an example for loading a .wav file. I managed to extract the initialization and finalization code for OpenAL from the FCL examples, but now the main part is the call alSourcePlay(buffer) , but I don't know how to populate the buffer with a WAV file.
Any hints or sample code. The sample included in FCL 2.4.1 loads MAD, A52, OGG and ModPlug only. Google revealed a tutorial using AlutLoadWavFile(), but that is in the "unofficial utilities library", it's not part of the standard OpenAL 1.1 spec, and not included in Linux.
Regards,
- Graeme -
If you can wait a few days, I'll extract a working windows/linux demo from my sourcode for you. Right now I'm really busy.
----- PŮVODNÍ ZPRÁVA -----
Od: "Graeme Geldenhuys"
Komu: "FPC-Pascal users discussions"
Předmět: Re: [fpc-pascal] playing sound files (linux and windows) Datum: 15.6.2010 - 13:29:43
Show quoted text 33 lines
Op 2010-06-15 13:30, het geskryf:
If you can wait a few days, I'll extract a working windows/linux demo from my sourcode for you. Right now I'm really busy.
That would be great thanks. I can wait... the sound support is for a new project that has no official starting date yet. I'm just gathering features and what FPC supports for that project.
Regards,
- Graeme -
Op 2010-06-14 18:28, dmitry boyarintsev het geskryf: I can't find an example for loading…
Graeme Geldenhuys wroteI can't find an example for loading a .wav file. I managed to extract the initialization and finalization code for OpenAL from the FCL examples, but now the main part is the call alSourcePlay(buffer) , but I don't know how to populate the buffer with a WAV file.
You can download the sample from here: http://havefunsoft.com/fpc/wavetest.zip The test has been modified to support .wav files.
Be warned, waveutils.pas is able to read uncompressed wav PCM files only. If .wav file uses anykind of the compression it would impossible to read it. Most of sound-processing applications allow to convert .wav to uncompressed form.
thanks,
dmitry
Op 2010-06-14 18:28, dmitry boyarintsev het geskryf: I can't find an example for loading…
Graeme Geldenhuys wroteI can't find an example for loading a .wav file.
[...]
Show quoted text 6 lines
ALUT is included in Linux, although usually in a separate package (libalut*). ALUT is "somewhat" official, that is it's development is coordinated on the same mailing list and, although separate to openal, I don't think it will die so soon :) ALUT spec is on http://connect.creativelabs.com/openal/Documentation/The%20OpenAL%20Utility%20Toolkit.htm
That said, loading uncompressed WAV files is quite easy, you can see my code on
https://vrmlengine.svn.sourceforge.net/svnroot/vrmlengine/trunk/kambi_vrml_game_engine/src/audio/soundfile.pas Look for TSoundWAV.CreateFromStream method.
Michalis
