Recent

Author Topic: Core Audio  (Read 2797 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 946
  • Former Delphi 1-7, 10.2 User
Re: Core Audio
« Reply #15 on: January 27, 2020, 05:59:22 am »
Thanks, I'll take a look. If it's working or I get it working, I'll add it to the https://wiki.lazarus.freepascal.org/Portal:Mac
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

AL

  • Full Member
  • ***
  • Posts: 181
Re: Core Audio
« Reply #16 on: February 04, 2020, 12:54:36 am »
Finnally found what was wrong with my charts and buttons, forms.
It was all caused by a Tspeedbutton that was on the form.  Once I replaced that with a tbutton everything was OK.  Might be a bug.  TSpeedButton will flip your form as a mirror image!

About the boolean:  Does it need to be ObjCBool everywhere or just in units with {$Mode ObjectiveC}
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

syntonica

  • Full Member
  • ***
  • Posts: 120
Re: Core Audio
« Reply #17 on: February 04, 2020, 04:44:09 am »
You only need to use it for flags that have to interface with ObjC. Otherwise, you can use a standard Boolean type.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #18 on: September 10, 2020, 03:59:42 pm »
Is there any examples for AVAudioEngine ?

AL

  • Full Member
  • ***
  • Posts: 181
Re: Core Audio
« Reply #19 on: September 10, 2020, 05:03:46 pm »
I have not found any in Lazarus/FPC.  There are examples in C if you google.
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #20 on: September 10, 2020, 08:13:24 pm »
Thanks, I'll try to find some example.

We need to use AVAudioEngine in manual mode, when we pass a sequence of audio buffers and calculate all audio effects manually with these buffers. It's necessary for existing cross-platform code (DirectSound on Windows).

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #21 on: September 14, 2020, 08:17:17 am »
Al,

We thought that AVAudioEngine is too complicated for our task, without examples of the code on FPC.

I saw that you tried to use Audio Queue Services.

Do you know, Audio Queue Services  is NOT deprecated yet, right?

If I understand rightly, Audio Queue Services (or AudioToolBox in general) are base for OpenAl and AVAudioEngine. So Apple should not deprecate this low-level audio API.

We have all sound processing with buffers (volume control, fading, dissolves) in a cross-platform code. And we simply need to organize a queue of sound buffers for a playback of audio from memory buffers. We use FFmpeg to decode various audio formats.
« Last Edit: September 14, 2020, 08:18:57 am by Igor Kokarev »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 946
  • Former Delphi 1-7, 10.2 User
Re: Core Audio
« Reply #22 on: September 14, 2020, 01:43:35 pm »
Do you know, Audio Queue Services  is NOT deprecated yet, right?

Correct.

Quote
If I understand rightly, Audio Queue Services (or AudioToolBox in general) are base for OpenAl and AVAudioEngine. So Apple should not deprecate this low-level audio API.

Be aware that OpenAL was deprecated at WWDC2019; to be removed in a future macOS release.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

AL

  • Full Member
  • ***
  • Posts: 181
Re: Core Audio
« Reply #23 on: September 14, 2020, 03:10:05 pm »
I wouild say AudioQueue is rather a high level service.  I am not sure it is based on openal, but I am not an Apple expert!
I also explored audioengine and audioHAL but could not make it work in Lazarus.
I was successfull using AudioQueue to record a microphone to a memory buffer.
Playing should be similar, but I have not tried it.
If you plan to use audioqueue I can repost my last code, so you have something to start with.
 
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #24 on: September 14, 2020, 11:37:13 pm »
Al,

Thanks, we started to learn Audio Queue Services to use it for a playback.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 946
  • Former Delphi 1-7, 10.2 User
Re: Core Audio
« Reply #25 on: September 15, 2020, 02:07:57 am »
I wouild say AudioQueue is rather a high level service.  I am not sure it is based on openal, but I am not an Apple expert!

It isn't. OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications. It (currently) comes pre-installed on macOS. Apple suggests transitioning to AVAudioEngine for spatial audio functionality.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

AL

  • Full Member
  • ***
  • Posts: 181
Re: Core Audio
« Reply #26 on: September 15, 2020, 04:20:57 am »
OK here is a comented very rough demo of AudioQueue.
It records 2 seconds of mono PCM 16 bits
As a bonus, you get a list of devices (recording in this case).
It should not be too difficult to modify it for stereo , 24 bits ,etc.
You will need to adjust the buffers sizes accordingly.
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #27 on: September 15, 2020, 10:13:30 am »
Al,

Many thanks for your example!

Igor Kokarev

  • Full Member
  • ***
  • Posts: 216
Re: Core Audio
« Reply #28 on: September 16, 2020, 08:50:45 am »
We successfully wrote a draft code. Audio Queue Services appeared to be much better API than OpenAl - more elegant and simple for our tasks.

And Audio Queue Services works fine on Apple DTK as native app for Apple Silicon. Currently OpenAl doesn't work on Apple DTK.

AL

  • Full Member
  • ***
  • Posts: 181
Re: Core Audio
« Reply #29 on: September 16, 2020, 02:09:57 pm »
Great!
Once you get it debugged, if you could post some code it would be a good addition to the Mac portal that Trev is maintaining. https://wiki.lazarus.freepascal.org/Portal:Mac
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

 

TinyPortal © 2005-2018