New version of the 'Audiere For Purebasic' pack

Developed or developing a new product in PureBasic? Tell the world about it.
bcgreen
User
User
Posts: 33
Joined: Sun Nov 02, 2003 7:33 am
Location: Pullman, WA

Post by bcgreen »

OK...so I tried windows MM, and no more crackling! BUT--some mp3 files won't open, while others will. I get an error saying "Error creating a new sample source"....and when opening an mp3 recorded at 22050hz, it plays back in double time! ....just checked, and the mp3s I can't open are 48000hz files....

Bryan
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

just have a look to your task manager/processes, and you'll see that ogg playing take more memory than mp3 (but less cpu time).

It was just a observation.

ps. I wrote only the include file for Purebasic. That's all.
We know that, but your include file is great :)
I think I will use it in my project.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

WolfGang, Im sorry I sounded so hard on you.. I really didnt mean to. And I want to thank you for providing the Include file for us PB users :) I just meant to say that I found the actual library (not the include file), lacking :)

Hey coma, where did you get your avatar at? I wanna make a poster for my daughter's room..
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

bcgreen wrote:OK...so I tried windows MM, and no more crackling! BUT--some mp3 files won't open, while others will. I get an error saying "Error creating a new sample source"....and when opening an mp3 recorded at 22050hz, it plays back in double time! ....just checked, and the mp3s I can't open are 48000hz files....
Bryan
Can you send me those files ?

MFG
WolfgangS
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

bcgreen wrote:OK...so I tried windows MM, and no more crackling! BUT--some mp3 files won't open, while others will. I get an error saying "Error creating a new sample source"....and when opening an mp3 recorded at 22050hz, it plays back in double time! ....just checked, and the mp3s I can't open are 48000hz files....
Bryan
Confirmed. I reported this information to the author of the libaray.

Thanks for your help !

MFG
WolfganGS
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

bcgreen wrote:Hmmm....I get lots of crackling in the audio that I don't get using any other mp3 player....
Try to increase the size of the buffer (try 500, 100, 300, 500, 10000) and tell me what happens please .

MFG
WolfgangS
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

bcgreen wrote:OK...so I tried windows MM, and no more crackling! BUT--some mp3 files won't open, while others will. I get an error saying "Error creating a new sample source"....and when opening an mp3 recorded at 22050hz, it plays back in double time! ....just checked, and the mp3s I can't open are 48000hz files....

Bryan
From the audiere logfile:

fixed: some MP3 were returning incorrect sample format info, so they sounded wrong

This is just for info ... now we have to wait for the next release :(

MFG
WolfgangS
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Anyone know where this is now, the link is dead... :(


-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Thanks :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Hi, guys.


As I was learning how to work with INTERFACES, I created a small AUDIERE include file based on WolfgangS interfaces. I removed some things to keep the code tight and replaced all CallFunction() with Prototypes. It works with AUDIERE version 1.9.4, AFAICT.

Have fun. :wink:


audiere.pbi

Code: Select all

Interface RefCounted 
   ref()                ; Long
   unref()              ; Long
EndInterface 


Interface file Extends RefCounted 
  _Read(pbuffer.l,size.l)      ; long
  seek(position.l,SeekMode.l)  ; bool
  tell()                       ; long
EndInterface


Interface SampleBuffer Extends RefCounted 
  getFormat(channel_count.l,sample_rate.l,sample_format.l)  ; void
  getLength()                                               ; long
  getSamples()                                              ; long
  openStream()                                              ; pSampleSource
EndInterface


Interface SampleSource Extends RefCounted 
  getFormat(long.l,long.l)      ; void
  Read(long.l,long.l)          ; long
  reset()                       ; void
  isSeekable()                  ; bool
  getLength()                   ; long
  setPosition(long.l)           ; void
  getPosition()                 ; long
  getRepeat()                   ; bool
  setRepeat(bool.l)             ; void
EndInterface


Interface LoopPointSource Extends SampleSource  
  addLoopPoint(location.l,target.l,loopCount.l)             ; void
  removeLoopPoint(index.l)                                  ; void
  getLoopPointCount()                                       ; long
  getLoopPoint(index.l,plocation.l,ptarget.l,ploopCount.l)  ; bool
EndInterface


Interface OutputStream Extends RefCounted 
  play() 
  stop()                 ; bool
  isPlaying()	          ; bool
  reset()                ; void
  setRepeat(bool.l)      ; void
  getRepeat()            ; bool
  setVolume(float.f)     ; void
  getVolume()            ; float
  setPan(float.f)        ; void
  getPan()               ; float
  setPitchShift(float.f) ; void
  getPitchShift()        ; float
  isSeekable()           ; bool
  getLength()            ; int
  setPosition(int.l)     ; void
  getPosition()          ; int
EndInterface


Interface AudioDevice Extends RefCounted
  update()                               ; void
  openStream(pSampleSource.l)            ; OutputStream.l
  openBuffer(pSamples.l,frame_count.l,channel_count.l,sample_rate.l,sample_format.l); OutputStream*
  getName()                              ; char.l
EndInterface


Interface SoundEffect Extends RefCounted 
  play()                          ; void
  stop()                          ; void
  setVolume(volume.f)             ; void
  getVolume()                     ; float
  setPan(pan.f)                   ; void
  getPan()                        ; float
  setPitchShift(shift.f)          ; void
  getPitchShift()                 ; float
EndInterface


Enumeration ; SampleFormat 
  #SF_U8      ; unsigned 8-bit integer [0,255]
  #SF_S16     ; signed 16-bit integer in host endianness [-32768,32767]
EndEnumeration


Enumeration ; FileFormat
  #FF_AUTODETECT
  #FF_WAV
  #FF_OGG
  #FF_FLAC
  #FF_MP3
  #FF_MOD
  #FF_AIFF
EndEnumeration


Enumeration ; SoundEffectType 
  #SINGLE
  #MULTIPLE
EndEnumeration


Enumeration ; SeekMode 
  #begin
  #current
  #End
EndEnumeration


audiere = OpenLibrary(#PB_Any, "audiere.dll")

Prototype.l _AdrCreateLoopPointSource(SampleSource.l)
Global AdrCreateLoopPointSource._AdrCreateLoopPointSource = GetFunction(audiere, "_AdrCreateLoopPointSource@4")

Prototype.l _AdrCreateMemoryFile(*Buffer, BufferSize.l)
Global AdrCreateMemoryFile._AdrCreateMemoryFile = GetFunction(audiere, "_AdrCreateMemoryFile@8")

Prototype.l _AdrCreatePinkNoise()
Global AdrCreatePinkNoise._AdrCreatePinkNoise = GetFunction(audiere, "_AdrCreatePinkNoise@0")

Prototype.l _AdrCreateSampleBuffer(*Samples, FrameCount.l, ChannelCount.l, SampleRate.l, SampleFormat.l)
Global AdrCreateSampleBuffer._AdrCreateSampleBuffer = GetFunction(audiere, "_AdrCreateSampleBuffer@20")

Prototype.l _AdrCreateSampleBufferFromSource(SampleSource.l)
Global AdrCreateSampleBufferFromSource._AdrCreateSampleBufferFromSource = GetFunction(audiere, "_AdrCreateSampleBufferFromSource@4")

Prototype.l _AdrCreateSquareWave(Frequency.d)
Global AdrCreateSquareWave._AdrCreateSquareWave = GetFunction(audiere, "_AdrCreateSquareWave@8")

Prototype.l _AdrCreateTone(Frequency.d)
Global AdrCreateTone._AdrCreateTone = GetFunction(audiere, "_AdrCreateTone@8")

Prototype.l _AdrCreateWhiteNoise()
Global AdrCreateWhiteNoise._AdrCreateWhiteNoise = GetFunction(audiere, "_AdrCreateWhiteNoise@0")

Prototype.l _AdrEnumerateCDDevices()
Global AdrEnumerateCDDevices._AdrEnumerateCDDevices = GetFunction(audiere, "_AdrEnumerateCDDevices@0")

Prototype.l _AdrGetSampleSize(SampleFormat.l)
Global AdrGetSampleSize._AdrGetSampleSize = GetFunction(audiere, "_AdrGetSampleSize@4")

Prototype.l _AdrGetSupportedAudioDevices()
Global AdrGetSupportedAudioDevices._AdrGetSupportedAudioDevices = GetFunction(audiere, "_AdrGetSupportedAudioDevices@0")

Prototype.l _AdrGetSupportedFileFormats()
Global AdrGetSupportedFileFormats._AdrGetSupportedFileFormats = GetFunction(audiere, "_AdrGetSupportedFileFormats@0")

Prototype.l _AdrGetVersion()
Global AdrGetVersion._AdrGetVersion = GetFunction(audiere, "_AdrGetVersion@0")

Prototype.l _AdrOpenCDDevice(DeviceName.s)
Global AdrOpenCDDevice._AdrOpenCDDevice = GetFunction(audiere, "_AdrOpenCDDevice@4")

Prototype.l _AdrOpenDevice(DeviceName.s, Options.s)
Global AdrOpenDevice._AdrOpenDevice = GetFunction(audiere, "_AdrOpenDevice@8")

Prototype.l _AdrOpenFile(Filename.s, Writeable.l)
Global AdrOpenFile._AdrOpenFile = GetFunction(audiere, "_AdrOpenFile@8")

Prototype.l _AdrOpenMIDIDevice(DeviceName.s)
Global AdrOpenMIDIDevice._AdrOpenMIDIDevice = GetFunction(audiere, "_AdrOpenMIDIDevice@4")

Prototype.l _AdrOpenSampleSource(Filename.s, FileFormat.l)
Global AdrOpenSampleSource._AdrOpenSampleSource = GetFunction(audiere, "_AdrOpenSampleSource@8")

Prototype.l _AdrOpenSampleSourceFromFile(FileHandle.l, FileFormat.l)
Global AdrOpenSampleSourceFromFile._AdrOpenSampleSourceFromFile = GetFunction(audiere, "_AdrOpenSampleSourceFromFile@8")

Prototype.l _AdrOpenSound(Device.l, SampleSource.l, Streaming.l)
Global AdrOpenSound._AdrOpenSound = GetFunction(audiere, "_AdrOpenSound@12")

Prototype.l _AdrOpenSoundEffect(Device.l, SoundSource.l, SoundEffectType.l)
Global AdrOpenSoundEffect._AdrOpenSoundEffect = GetFunction(audiere, "_AdrOpenSoundEffect@12")


example.pb

Code: Select all

IncludeFile "audiere.pb"


If OpenWindow(0, #PB_Ignore, #PB_Ignore, 320, 200, "Audiere Demo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	If CreateGadgetList(WindowID(0))
		ButtonGadget(0, WindowWidth(0)/2-100, WindowHeight(0)/2-20, 200, 40, "AUDIERE Sample")
	EndIf
EndIf

Debug PeekS(AdrGetVersion())
Debug PeekS(AdrEnumerateCDDevices())
Debug PeekS(AdrGetSupportedAudioDevices())
Debug PeekS(AdrGetSupportedFileFormats())


device.AudioDevice = AdrOpenDevice("winmm", "buffer=1000,rate=44100")

If device
	source.SampleSource = AdrOpenSampleSource("12 - CHANGE THE FUTURE.mp3",#FF_AUTODETECT)
	If source
		stream.OutputStream = AdrOpenSound(device, source, #True)
		
		device\ref()
		source\ref()
		stream\ref()
		
		stream\play()
	EndIf
EndIf

Repeat
	event = WaitWindowEvent()
	
	Select event
		Case #PB_Event_CloseWindow
			Fim = #True
			
		Case #PB_Event_Gadget
			Select EventGadget()
				Case 0
					If stream\isPlaying()
						stream\stop()
					Else
						stream\play()
					EndIf
			EndSelect
			
	EndSelect

Until Fim

If stream\isPlaying()
	stream\stop()
EndIf

stream\unref()
source\unref()
device\unref()
.
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: New version of the 'Audiere For Purebasic' pack

Post by TomS »

Hi, thanks for posting the code, since WolfgangS' page is offline.
But I get an IMA (at Adresse: 0) at line 40 (in the example): If stream\isPlaying() (after clicking the button, ofcourse).
I have the audiere.dll 1.9.4
The dll can be downloaded here: http://audiere.sourceforge.net/download.php
The manual can be found here, if that helps: http://audiere.sourceforge.net/audiere- ... s-doxygen/

I hope someone can help me.
User avatar
happer66
User
User
Posts: 33
Joined: Tue Jan 12, 2010 12:10 pm
Location: Sweden

Re: New version of the 'Audiere For Purebasic' pack

Post by happer66 »

Did you set

Code: Select all

source.SampleSource = AdrOpenSampleSource("12 - CHANGE THE FUTURE.mp3",#FF_AUTODETECT)
to point to a valid file?

That same line you mentioned also fails if you're trying to compile a unicode executable...
Image If your code isn't clean atleast make sure it's pure!
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: New version of the 'Audiere For Purebasic' pack

Post by TomS »

happer66 wrote:Did you set

source.SampleSource = AdrOpenSampleSource("12 - CHANGE THE FUTURE.mp3",#FF_AUTODETECT)

to point to a valid file?
No. What a fool I am :shock: :oops:

Thanks so much :)
Post Reply