Author Topic: Getting started in Delphi  (Read 440 times)

MikeatBookup

  • Posts: 32
Getting started in Delphi
« on: 8 Sep '21 - 03:12 »
Delphi programmer here. (I have zero knowledge of C or Java.)

My app runs on Windows, MacOS, iOS, and Android.

My Delphi app needs to record audio from the microphone on all four of those platforms and play it back on all four of those platforms, interchangeably. That is, I need to record on any platform and play back audio on all four platforms.

Can BASS enable me to do this? If so, where should I start?

Chris

  • Posts: 1981
Re: Getting started in Delphi
« Reply #1 on: 8 Sep '21 - 09:00 »
Hi, yes that possible in Delphi with FMX (Firemonkey) .
So you will need only the different Libs from Bass for win32,win64, MacOS, iOS, and Android.

One important thing FMX don`t know any Ansi Stuff (eg Ansistring, Ansichar and so on) FMX only allowed  Unicode.
so here  can you find a nice Bass.pas Unit what will tie up the Plattforms. https://github.com/TDDung/DelphiFMX-BASS/blob/main/FMX-BASSVersion/BASS/FMX.BASS.pas

Here you  can find also an small demo
https://github.com/TDDung/DelphiFMX-BASS/tree/main/FMX-BASSVersion


MikeatBookup

  • Posts: 32
Re: Getting started in Delphi
« Reply #2 on: 22 Sep '21 - 16:30 »
Thanks, Chris. That got me rolling. I was able to get the tiny FMX demo program running.

I'm having trouble finding example code that records MP3 on mobile (iOS and Android).

Ian @ un4seen

  • Administrator
  • Posts: 23938
Re: Getting started in Delphi
« Reply #3 on: 23 Sep '21 - 13:57 »
The easiest way to record to MP3 is with the BASSenc and BASSenc_MP3 add-ons. The code could look something like this:

Code: [Select]
BASS_RecordInit(-1); // initialize default recording device
hrecord = BASS_RecordStart(44100, 2, 0, RecordProc, 0); // start recording
BASS_Encode_MP3_StartFile(hrecord, "", BASS_ENCODE_AUTOFREE, filename); // start encoding to MP3 file

...

BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
    return TRUE; // continue recording
}

...

BASS_ChannelStop(hrecord); // stop recording (and encoding due to AUTOFREE)

That's C/C++ but it'll look much the same in Delphi. Please see the documentation for details on the mentioned functions.

MikeatBookup

  • Posts: 32
Re: Getting started in Delphi
« Reply #4 on: 24 Sep '21 - 18:11 »
I'm using the Delphi FMX.Bass from
https://github.com/TDDung/DelphiFMX-BASS/tree/main/FMX-BASSVersion

It makes available BASS_GetVersion()
 but not BASS_ENC_MP3_GetVersion().

What must I add to support encoding MP3 for iOS?


TDDung

  • Posts: 31
Re: Getting started in Delphi
« Reply #5 on: 24 Sep '21 - 19:47 »
DelphiFMX-BASS (FMX only, no add-on) is older and less capable than Delphi-BASS (FMX & VCL plus add-ons)  :) You will be happy with Delphi-BASS

Note: check my posts here https://www.un4seen.com/forum/?topic=19234 and here https://www.un4seen.com/forum/?topic=19384.0

TDDung

  • Posts: 31
Re: Getting started in Delphi
« Reply #6 on: 24 Sep '21 - 20:02 »
You can now do like this with Delphi-BASS ;D

The easiest way to record to MP3 is with the BASSenc and BASSenc_MP3 add-ons. The code could look something like this:

Code: [Select]
BASS_RecordInit(-1); // initialize default recording device
hrecord = BASS_RecordStart(44100, 2, 0, RecordProc, 0); // start recording
BASS_Encode_MP3_StartFile(hrecord, "", BASS_ENCODE_AUTOFREE, filename); // start encoding to MP3 file

...

BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
    return TRUE; // continue recording
}

...

BASS_ChannelStop(hrecord); // stop recording (and encoding due to AUTOFREE)

That's C/C++ but it'll look much the same in Delphi. Please see the documentation for details on the mentioned functions.