PDA

View Full Version : Looking for a free playback library



masonwheeler
28-07-2007, 01:38 PM
I want to find a component that can play back pretty much any sound format through DirectWhateverThey'reUsingForThatTheseDays, but won't charge me an arm and a leg if I want to use it commercially. It doesn't have to have a ton of features for editing files or streaming them or heaven-only-knows-what else, like FMOD and BASS do (which no doubt contributes to their high licensing cost,) but it has to be able to play back any format, including MIDI, which nothing I've seen except BASS supports, unless it's a MIDI-only component.

Does any package like this exist? If so, where can I find it?

Mason

arthurprs
28-07-2007, 06:12 PM
use BASS simple and powerfull :)

arthurprs
28-07-2007, 06:13 PM
use BASS simple and powerfull :)
"The BASS library is free for non-commercial use. If you are a non-commercial entity and are not charging for your software, and the software has no other commercial purpose, then you can use BASS in it for free."

masonwheeler
03-08-2007, 03:44 PM
*sigh*
*points Arthurprs back to his original post, where BASS is specifically mentioned as being unsuitable*

Mirage
03-08-2007, 04:06 PM
Audiere. Very nice free library.
Don't know if it plays midi, but it plays mp3, ogg, xm, it, etc...

Robert Kosek
03-08-2007, 04:46 PM
No offense, but this is the only mention of Audiere on the forums. The only implementation of Audiere in pascal I have seen is at Asphyre, but was never actually finished. Furthermore, Pascal headers aren't included with Audiere.

If you're going to name a package, at least tell where you can get a pascal or Delphi compatible header. And yes, I have looked.

Edit: For the record I only found the Delphi binding through SVN. Fun... :roll:

Mirage
03-08-2007, 08:10 PM
A header I have has link to http://www.gamevisionsdk.com
But it abandoned and taken by cybersquatters. :(
Nevertheless, Audiere with this header is working well.
I wanted to attach the header to my post but didn't found how to do this.

Robert Kosek
03-08-2007, 09:05 PM
No it isn't. Jarrod Davis just can't sit on a website name for longer than2 months, or keep a product name the same for more than a year. Try http://www.pyrogine.com/ to see the current site. (And in case you're wondering Jarrod (in the off chance you read this), yes this is why I left. Nothing stayed the same, no old threads with helpful functions remained, no old members.)

Here is the binding I got through the SVN. Sorry for the tone; I just get bothered when people don't share links. :)

Audiere.pas:
//================================================== =======================
// Audiere Sound System
// Version 1.9.2
// (c) 2002 Chad Austin
//
// This API uses principles explained at
// http://aegisknight.org/cppinterface.html
//
// This code licensed under the terms of the LGPL. See the Audiere
// license.txt.
//-------------------------------------------------------------------------
// Delphi Conversion By:
// Jarrod Davis
// Jarrod Davis Software
// http://www.jarroddavis.com - Jarrod Davis Software
// http://www.gamevisionsdk.com - Game Application Framework for Delphi
// support@jarroddavis.com - Support Email
//-------------------------------------------------------------------------
// How to use:
// * Include Audiere in your Uses statement
// * Enable or Disable the DYNAMICS compiler define
// * If Dynamic, be sure to call AdrLoadDLL before using any commands.
// the DLL will be automaticlly unloaded at termination.
// * If Static, then use as normal.
// History:
// * Initial 1.9.2 release.
// + Added dynamic loading. Use the DYNAMIC compiler define to control
// this. When enabled you can then use ArdLoadLL/AdrUnloadDLL to
// dynamiclly load/unload dll at runtime.
//================================================== =======================

unit Audiere;

{$A+}
{$Z4}
{$DEFINE DYNAMIC}

interface

const
DLL_NAME = 'Audiere.dll';

type

{ TAdrSeekMode }
TAdrSeekMode = (
Adr_Seek_Begin,
Adr_Seek_Current,
Adr_Seek_End
);

{ TAdrSoundEffectType }
TAdrSoundEffectType = (
Adr_SoundEffectType_Single,
Adr_SoundEffectType_Multiple
);

{ TAdrSampleFormat }
TAdrSampleFormat = (
Adr_SampleFormat_U8,
Adr_SampleFormat_S16
);

{ TAdrFileFormat }
TAdrFileFormat = (
FF_AUTODETECT,
FF_WAV,
FF_OGG,
FF_FLAC,
FF_MP3,
FF_MOD
);

{ TAdrRefCounted }
TAdrRefCounted = class
public
procedure Ref; virtual; stdcall; abstract;
procedure UnRef; virtual; stdcall; abstract;
end;

{ TAdrFile }
TAdrFile = class(TAdrRefCounted)
public
function Read(aBuffer: Pointer; aSize: Integer): Integer; virtual; stdcall; abstract;
function Seek(aPosition: Integer; aSeekMode: TAdrSeekMode): Boolean; virtual; stdcall; abstract;
function Tell: Integer; virtual; stdcall; abstract;
end;

{ TAdrSampleSource }
TAdrSampleSource = class(TAdrRefCounted)
public
procedure GetFormat(var aChannelCount: Integer; var aSampleRate: Integer; var aSampleFormat: TAdrSampleFormat); virtual; stdcall; abstract;
function Read(aFrameCount: Integer; aBuffer: Pointer): Integer; virtual; stdcall; abstract;
procedure Reset; virtual; stdcall; abstract;
function IsSeekable: Boolean; virtual; stdcall; abstract;
function GetLength: Integer; virtual; stdcall; abstract;
procedure SetPosition(Position: Integer); virtual; stdcall; abstract;
function GetPosition: Integer; virtual; stdcall; abstract;
end;

{ TAdrOutputStream }
TAdrOutputStream = class(TAdrRefCounted)
public
procedure Play; virtual; stdcall; abstract;
procedure Stop; virtual; stdcall; abstract;
function IsPlaying: Boolean; virtual; stdcall; abstract;
procedure Reset; virtual; stdcall; abstract;
procedure SetRepeat(aRepeat: Boolean); virtual; stdcall; abstract;
function GetRepeat: Boolean; virtual; stdcall; abstract;
procedure SetVolume(aVolume: Single); virtual; stdcall; abstract;
function GetVolume: Single; virtual; stdcall; abstract;
procedure SetPan(aPan: Single); virtual; stdcall; abstract;
function GetPan: Single; virtual; stdcall; abstract;
procedure SetPitchShift(aShift: Single); virtual; stdcall; abstract;
function GetPitchShift: Single; virtual; stdcall; abstract;
function IsSeekable: Boolean; virtual; stdcall; abstract;
function GetLength: Integer; virtual; stdcall; abstract;
procedure SetPosition(aPosition: Integer); virtual; stdcall; abstract;
function GetPosition: Integer; virtual; stdcall; abstract;
end;

{ TAdrAudioDevice }
TAdrAudioDevice = class(TAdrRefCounted)
public
procedure Update; virtual; stdcall; abstract;
function OpenStream(aSource: TAdrSampleSource): TAdrOutputStream; virtual; stdcall; abstract;
function OpenBuffer(aSamples: Pointer; aFrameCount, aChannelCount, aSampleRate: Integer; aSampelFormat: TAdrSampleFormat): TAdrOutputStream; virtual; stdcall; abstract;
end;

{ TAdrSampleBuffer }
TAdrSampleBuffer = class(TAdrRefCounted)
public
procedure GetFormat(var ChannelCount: Integer; var aSampleRate: Integer; var aSampleFormat: TAdrSampleFormat); virtual; stdcall; abstract;
function GetLength: Integer; virtual; stdcall; abstract;
function GetSamples: Pointer; virtual; stdcall; abstract;
function OpenStream: TAdrSampleSource; virtual; stdcall; abstract;
end;

{ TAdrSoundEffect }
TAdrSoundEffect = class(TAdrRefCounted)
public
procedure Play; virtual; stdcall; abstract;
procedure Stop; virtual; stdcall; abstract;
procedure SetVolume(aVolume: Single); virtual; stdcall; abstract;
function GetVolume: Single; virtual; stdcall; abstract;
procedure SetPan(aPan: Single); virtual; stdcall; abstract;
function GetPan: Single; virtual; stdcall; abstract;
procedure SetPitchShift(aShift: Single); virtual; stdcall; abstract;
function GetPitchShift: Single; virtual; stdcall; abstract;
end;

{ --- Audiere Routines -------------------------------------------------- }
{$IFNDEF DYNAMIC}
function AdrGetVersion: PChar; stdcall; external DLL_NAME name '_AdrGetVersion@0';
function AdrGetSupportedFileFormats: PChar; stdcall; external DLL_NAME name '_AdrGetSupportedFileFormats@0';
function AdrGetSupportedAudioDevices: PChar; stdcall; external DLL_NAME name '_AdrGetSupportedAudioDevices@0';
function AdrGetSampleSize(aFormat: TAdrSampleFormat): Integer; stdcall; external DLL_NAME name '_AdrGetSampleSize@4';
function AdrOpenDevice(const aName: PChar; const aParams: PChar): TAdrAudioDevice; stdcall; external DLL_NAME name '_AdrOpenDevice@8';
function AdrOpenSampleSource(const aFilename: PChar; aFileFormat: TAdrFileFormat): TAdrSampleSource; stdcall; external DLL_NAME name '_AdrOpenSampleSource@8';
function AdrOpenSampleSourceFromFile(aFile: TAdrFile; aFileFormat: TAdrFileFormat): TAdrSampleSource; stdcall; external DLL_NAME name '_AdrOpenSampleSourceFromFile@8';
function AdrCreateTone(aFrequency: Double): TAdrSampleSource; stdcall; external DLL_NAME name '_AdrCreateTone@8';
function AdrCreateSquareWave(aFrequency: Double): TAdrSampleSource; stdcall; external DLL_NAME name '_AdrCreateSquareWave@8';
function AdrCreateWhiteNoise: TAdrSampleSource; stdcall; external DLL_NAME name '_AdrCreateWhiteNoise@0';
function AdrCreatePinkNoise: TAdrSampleSource; stdcall; external DLL_NAME name '_AdrCreatePinkNoise@0';
function AdrOpenSound(aDevice: TAdrAudioDevice; aSource: TAdrSampleSource; aStreaming: LongBool): TAdrOutputStream; stdcall; external DLL_NAME name '_AdrOpenSound@12';
function AdrCreateSampleBuffer(aSamples: Pointer; aFrameCount, aChannelCount, aSampleRate: Integer; aSampleFormat: TAdrSampleFormat): TAdrSampleBuffer; stdcall; external DLL_NAME name '_AdrCreateSampleBuffer@20';
function AdrCreateSampleBufferFromSource(aSource: TAdrSampleSource): TAdrSampleBuffer; stdcall; external DLL_NAME name '_AdrCreateSampleBufferFromSource@4';
function AdrOpenSoundEffect(aDevice: TAdrAudioDevice; aSource: TAdrSampleSource; aType: TAdrSoundEffectType): TAdrSoundEffect; stdcall; external DLL_NAME name '_AdrOpenSoundEffect@12';
{$ENDIF}

{$IFDEF DYNAMIC}
var
AdrGetVersion : function: PChar; stdcall = nil;
AdrGetSupportedFileFormats : function: PChar; stdcall = nil;
AdrGetSupportedAudioDevices : function : PChar; stdcall = nil;
AdrGetSampleSize : function(aFormat: TAdrSampleFormat): Integer; stdcall = nil;
AdrOpenDevice : function(const aName: PChar; const aParams: PChar): TAdrAudioDevice; stdcall = nil;
AdrOpenSampleSource : function(const aFilename: PChar; aFileFormat: TAdrFileFormat): TAdrSampleSource; stdcall = nil;
AdrOpenSampleSourceFromFile : function(aFile: TAdrFile; aFileFormat: TAdrFileFormat): TAdrSampleSource; stdcall = nil;
AdrCreateTone : function(aFrequency: Double): TAdrSampleSource; stdcall = nil;
AdrCreateSquareWave : function(aFrequency: Double): TAdrSampleSource; stdcall = nil;
AdrCreateWhiteNoise : function: TAdrSampleSource; stdcall = nil;
AdrCreatePinkNoise : function: TAdrSampleSource; stdcall = nil;
AdrOpenSound : function(aDevice: TAdrAudioDevice; aSource: TAdrSampleSource; aStreaming: LongBool): TAdrOutputStream; stdcall = nil;
AdrCreateSampleBuffer : function(aSamples: Pointer; aFrameCount, aChannelCount, aSampleRate: Integer; aSampleFormat: TAdrSampleFormat): TAdrSampleBuffer; stdcall = nil;
AdrCreateSampleBufferFromSource: function(aSource: TAdrSampleSource): TAdrSampleBuffer; stdcall = nil;
AdrOpenSoundEffect : function(aDevice: TAdrAudioDevice; aSource: TAdrSampleSource; aType: TAdrSoundEffectType): TAdrSoundEffect; stdcall = nil;

function AdrLoadDLL: Boolean; stdcall;
procedure AdrUnloadDLL; stdcall;
{$ENDIF}

implementation

{$IFDEF DYNAMIC}
uses
Windows;

var
AdrDLL: HMODULE = 0;

function AdrLoadDLL: Boolean;
begin
Result := False;

AdrDLL := LoadLibrary('audiere.dll');
if(AdrDLL = 0) then
begin
Exit;
end;

@AdrGetVersion := GetProcAddress(AdrDLL, '_AdrGetVersion@0');
@AdrGetSupportedFileFormats := GetProcAddress(AdrDLL, '_AdrGetSupportedFileFormats@0');
@AdrGetSupportedAudioDevices := GetProcAddress(AdrDLL, '_AdrGetSupportedAudioDevices@0');
@AdrGetSampleSize := GetProcAddress(AdrDLL, '_AdrGetSampleSize@4');
@AdrOpenDevice := GetProcAddress(AdrDLL, '_AdrOpenDevice@8');
@AdrOpenSampleSource := GetProcAddress(AdrDLL, '_AdrOpenSampleSource@8');
@AdrOpenSampleSourceFromFile := GetProcAddress(AdrDLL, '_AdrOpenSampleSourceFromFile@8');
@AdrCreateTone := GetProcAddress(AdrDLL, '_AdrCreateTone@8');
@AdrCreateSquareWave := GetProcAddress(AdrDLL, '_AdrCreateSquareWave@8');
@AdrCreateWhiteNoise := GetProcAddress(AdrDLL, '_AdrCreateWhiteNoise@0');
@AdrCreatePinkNoise := GetProcAddress(AdrDLL, '_AdrCreatePinkNoise@0');
@AdrOpenSound := GetProcAddress(AdrDLL, '_AdrOpenSound@12');
@AdrCreateSampleBuffer := GetProcAddress(AdrDLL, '_AdrCreateSampleBuffer@20');
@AdrCreateSampleBufferFromSource := GetProcAddress(AdrDLL, '_AdrCreateSampleBufferFromSource@4');
@AdrOpenSoundEffect := GetProcAddress(AdrDLL, '_AdrOpenSoundEffect@12');

if not Assigned(AdrGetVersion) then Exit;
if not Assigned(AdrGetSupportedFileFormats) then Exit;
if not Assigned(AdrGetSupportedAudioDevices) then Exit;
if not Assigned(AdrGetSampleSize) then Exit;
if not Assigned(AdrOpenDevice) then Exit;
if not Assigned(AdrOpenSampleSource) then Exit;
if not Assigned(AdrOpenSampleSourceFromFile) then Exit;
if not Assigned(AdrCreateTone) then Exit;
if not Assigned(AdrCreateSquareWave) then Exit;
if not Assigned(AdrCreateWhiteNoise) then Exit;
if not Assigned(AdrCreatePinkNoise) then Exit;
if not Assigned(AdrOpenSound) then Exit;
if not Assigned(AdrCreateSampleBuffer) then Exit;
if not Assigned(AdrCreateSampleBufferFromSource) then Exit;
if not Assigned(AdrOpenSoundEffect) then Exit;

Result := True;
end;

procedure AdrUnloadDLL;
begin
if AdrDLL <> 0 then
begin
FreeLibrary&#40;AdrDLL&#41;;
AdrDLL &#58;= 0;
end;
end;

initialization
begin
end;

finalization
begin
AdrUnLoadDLL;
end;

&#123;$ENDIF&#125;

end.

arthurprs
04-08-2007, 01:07 AM
*sigh*
*points Arthurprs back to his original post, where BASS is specifically mentioned as being unsuitable*

Sorry, i have read only the title and file formats :oops:

masonwheeler
04-08-2007, 01:12 AM
That's a very nice-looking header, Robert. But it doesn't look like it does MIDI. :(

You know anything that does?

Mason

Firlefanz
04-08-2007, 08:07 AM
Squallsound is great stuff and totally free.
I use it for SFX and music with OGG.

But I am not sure if it plays midi ;)

Mirage
04-08-2007, 12:10 PM
Squall most likely will become commercial AFAIK.
I used Audiere in two commercial products as well as in my competition entry and had no problems.
The header I have is same as posted by Robert.
MIDI files can be played by OS services.

Ingemar
16-05-2009, 07:41 AM
Bumping old thread on a subject that I find important.

I never heard of Audiere before, but it is out of the question for me since it has no Mac support.

What would you suggest for FPC friendly cross-platform audio? My main alternatives right now are SDL mixer and OpenAL. Any opinions about these? License, installation, usage? Other interesting alternatives?

chronozphere
16-05-2009, 08:49 AM
Normally I would recommend OpenAL because it has a really nice API and it's cross-platform. But i just took a closer look at SDL-mixer and i must say that I'm impressed. It seems to support WAV, MOD, MIDI, OGG and MP3 out of the box. :D

They're both good options, but If you're allready using SDL for graphics and input, I'd definitely pick the SDL-mixer. :)