Author Topic: BASS for iOS (iPhone/iPad)  (Read 770185 times)

Fischert

  • Posts: 4
Re: BASS for iOS (iPhone/iPad)
« Reply #1475 on: 19 Mar '22 - 22:25 »
Hi mdaskal,

That sounds very interesting! Pls. keep me informed!!

Best regards
Thomas

mdaskal

  • Posts: 7
Re: BASS for iOS (iPhone/iPad)
« Reply #1476 on: 25 Mar '22 - 18:08 »
Hi mdaskal,

That sounds very interesting! Pls. keep me informed!!

Best regards
Thomas

Hi Thomas,
We could finalize the integration of the BASSMIDI library into an AUv3, and it works perfectly well!
Best wishes
 

Fischert

  • Posts: 4
Re: BASS for iOS (iPhone/iPad)
« Reply #1477 on: 13 Apr '22 - 06:01 »
Hi mdaskal,

Congratulations!!

Is it possible to get that AUv3?

Best regards
Thomas

Dorian

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1478 on: 19 Aug '22 - 16:18 »
Can't access the sample app and I can't seem to #import or #include the bass.h file into an iOS objective c code.


Okay, here is a sample app, demonstrating how to make BASS play back music in the background, and control playback with the multitask bar controls. Actually the app can also be remote controlled with some 3rd party iPhone accessories and speakers.

http://cl.ly/4513342M223M3v0s2Y3T

ECSalute

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1479 on: 9 Sep '22 - 08:10 »
Additional setup steps (may be useful for other people)
> Drag bass.h into your project
> OPTIONAL : create a Header.h file and #include bass.h
> Link your header file with your project (Objective C bridging Header)
> Build
> OPTIONAL : Abilitate "Allow Arbitrary Loads" in "App transport security settings"

With this bass works with my project

mdaskal

  • Posts: 7
Re: BASS for iOS (iPhone/iPad)
« Reply #1480 on: 5 Oct '22 - 16:29 »
Hi mdaskal,

Congratulations!!

Is it possible to get that AUv3?

Best regards
Thomas

Hi Thomas,

We finally could take the time to publish a repository on Github with our AUv3 Audio Unit embedding the BASSMIDI player.
For those interested you can find it here:
https://github.com/newzik/BassMidiAudioUnit

Any suggestions or feedback are welcome !
Best,

rrhh_fx

  • Posts: 39
Re: BASS for iOS (iPhone/iPad)
« Reply #1481 on: 9 Dec '22 - 08:34 »
Hi,

I am trying to integrate the Bass 2.4 library in a Swift iOS project in Xcode 14.1 with a MacBook Air M1 with no success. The steps are next:

1) In General -> Frameworks, libraries and Embedded Content, click on the "+" button and add the Bass xcframework library (plus the rest of required frameworks indicated in the OP)
2) In Build Phases -> Link binary with libraries -> Status required
3) In Build Settings -> Enable bitcode -> "No"

If trying to use the lib in a Swift file using "import BASS" sentence at the top, always the "not such module 'BASS'" is showing.

Any help is appreciated

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1482 on: 9 Dec '22 - 15:25 »
I'm not a Swift user myself, so I'm not sure if there's a better way to do it, but I believe you need to create a "bridging header" to use C framework/library headers. For example, create a "bridging-header.h" file containing this:

Code: [Select]
#include "bass.h"
// #include any add-on headers here too...

And then set "Objective-C Bridging Header" to "bridging-header.h" in your project's settings. The BASS header(s) should be placed alongside it (or somewhere in the header search path).

Btw, with the switch to dynamic libraries in BASS 2.4.17, any dependency frameworks can be (and are) specified in the BASS libraries themselves, so there's no need to include them to your project's settings any more.

rrhh_fx

  • Posts: 39
Re: BASS for iOS (iPhone/iPad)
« Reply #1483 on: 10 Dec '22 - 10:26 »
I'm not a Swift user myself, so I'm not sure if there's a better way to do it, but I believe you need to create a "bridging header" to use C framework/library headers. For example, create a "bridging-header.h" file containing this:

Code: [Select]
#include "bass.h"
// #include any add-on headers here too...

And then set "Objective-C Bridging Header" to "bridging-header.h" in your project's settings. The BASS header(s) should be placed alongside it (or somewhere in the header search path).

Btw, with the switch to dynamic libraries in BASS 2.4.17, any dependency frameworks can be (and are) specified in the BASS libraries themselves, so there's no need to include them to your project's settings any more.

Thank you Ian. The bridging header works nice


reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1484 on: 27 Nov '23 - 16:33 »
I'm getting an exception that I can't figure out how to handle. It's in an app that we've been distributing for years.
Here is the trace (attached png)

I tried catching the exception but it doesn't appear to be working:
Code: [Select]

Debug.WriteLine("pause called");
try
{
   Bass.BASS_Pause();
}
catch (Exception ex)
{
   Debug.WriteLine(ex.Message);
}

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1485 on: 27 Nov '23 - 16:53 »
That's strange. To get more info on the problem, is it possible to disable Mono/Xamarin's exception handling and let the OS catch the crash instead to generate a native crash report? Please also confirm what BASS version you're using (with BASS_GetVersion), and try upgrading if it isn't the latest.

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1486 on: 4 Dec '23 - 16:28 »
That's strange. To get more info on the problem, is it possible to disable Mono/Xamarin's exception handling and let the OS catch the crash instead to generate a native crash report? Please also confirm what BASS version you're using (with BASS_GetVersion), and try upgrading if it isn't the latest.
GetVersion returns:
33820417

I don't see in Visual Studio for Mac where to disable Xamarin's exception handling.
I'm going to try generating a beta with full symbols. I can't get the crash to happen in a simulator, only on a real device with CarPlay when there is that route change it appears.


Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1487 on: 4 Dec '23 - 17:07 »
33820417 is 2.4.15.1, which is quite old. So please do also try upgrading to the latest BASS version and see if you still have the problem then.

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1488 on: 4 Dec '23 - 19:40 »
33820417 is 2.4.15.1, which is quite old. So please do also try upgrading to the latest BASS version and see if you still have the problem then.
From what I can tell the current releases use dynamic libs instead of static libs. Is that the case?
If so, is there somewhere you can point me to with regards to how to implement those?

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1489 on: 5 Dec '23 - 13:19 »
Yes, the iOS BASS libraries are now dynamic (in an XCFramework) rather than static. First remove the old static library(s) from your Xcode project's "Frameworks, Libraries, and Embedded Content" section (also check the "Build Phases" to be sure), and then add the new XCFramework(s) and set it to "Embed & Sign".

reb

  • Posts: 15
Re: BASS for iOS (iPhone/iPad)
« Reply #1490 on: 7 Dec '23 - 15:32 »
Yes, the iOS BASS libraries are now dynamic (in an XCFramework) rather than static. First remove the old static library(s) from your Xcode project's "Frameworks, Libraries, and Embedded Content" section (also check the "Build Phases" to be sure), and then add the new XCFramework(s) and set it to "Embed & Sign".
The project is in Visual Studio for Mac using Xamarim mono. I assume it will be similar.
In the project settings under additional arguments I currently have:
Code: [Select]
-cxx -gcc_flags "-L${ProjectDir}/Bass/ -framework accelerate -framework AudioToolbox -framework CoreMIDI -force_load ${ProjectDir}/Bass/libbass.a -force_load ${ProjectDir}/Bass/libbassmix.a -force_load ${ProjectDir}/Bass/libbassflac.a -force_load ${ProjectDir}/Bass/libbass_mpc.a -force_load ${ProjectDir}/Bass/libbasswv.a -force_load ${ProjectDir}/Bass/libbassdsd.a "
« Last Edit: 7 Dec '23 - 16:07 by reb »

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1491 on: 8 Dec '23 - 16:48 »
You could try replacing those "-force_load" options with "-framework", eg. "-framework bass". And "-L${ProjectDir}/Bass/" with "-F${ProjectDir}/Bass/".

rrhh_fx

  • Posts: 39
Re: BASS for iOS (iPhone/iPad)
« Reply #1492 on: 8 Feb '24 - 12:12 »
In Swift, to produce a noteOn event, next sentence is used:

Code: [Select]
BASS_MIDI_StreamEvent(stream, channel, DWORD(MIDI_EVENT_NOTE), DWORD(makeWord(midiNote, Int(speed))))
However, when trying to use the MIDI_EVENTS_NOTE_OFF using next sentence:

Code: [Select]
let a = BASS_MIDI_StreamEvent(stream, DWORD(channel), DWORD(MIDI_EVENT_NOTESOFF), DWORD(0))
the note played in first sentence is not stopped as expected. Or if used after a MIDI_EVENT_SUSTAIN On event, notes are not stopping as expected. The previous approach is working in Android with no issues, and the return of MIDI_EVENT_NOTESOFF in this case is true. Simply, notes are not stopping. What can be happening? Thanks

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1493 on: 8 Feb '24 - 14:08 »
MIDI_EVENT_NOTESOFF (cc#123) releases all keys but it doesn't necessarily stop the notes. When sustain (cc#64) is switched on, the notes won't be released until that's switched off. Even when a note is released, it might not stop immediately due to its envelope in the soundfont. If you would like to immediately stop all notes then you can use MIDI_EVENT_SOUNDOFF (cc#120) instead.

If this doesn't explain what you're seeing then please provide a call/event sequence to reproduce the problem with. I tried a MIDI_EVENT_NOTE followed by a MIDI_EVENT_NOTESOFF (as above) and that seemed to be working fine, ie. the note was released and it faded-out according to its envelope.

rrhh_fx

  • Posts: 39
Re: BASS for iOS (iPhone/iPad)
« Reply #1494 on: 9 Feb '24 - 09:13 »
MIDI_EVENT_NOTESOFF (cc#123) releases all keys but it doesn't necessarily stop the notes. When sustain (cc#64) is switched on, the notes won't be released until that's switched off. Even when a note is released, it might not stop immediately due to its envelope in the soundfont. If you would like to immediately stop all notes then you can use MIDI_EVENT_SOUNDOFF (cc#120) instead.

If this doesn't explain what you're seeing then please provide a call/event sequence to reproduce the problem with. I tried a MIDI_EVENT_NOTE followed by a MIDI_EVENT_NOTESOFF (as above) and that seemed to be working fine, ie. the note was released and it faded-out according to its envelope.

In my case, Sustain is switched on, and then a note from a SF with a sample with infinite loop is played. That sound will be played continuously. When MIDI_EVENT_SOUNDOFF is triggered, instead of follow its envelope (that also is contained) until the sound is faded out, the sound keeps playing with no changes, like if the command was not sent (and it is returning true). In Android I do the same (the same SF, and the same commands and it is working as expected). I have tried with several SF2 files.

MIDI_EVENT_SOUNDOFF is working fine, but as you say, it cuts sound and does not keep the SF curve.

BASS and BASS_MIDI versions are 2.4.17.0 and 2.4.14.1 respectively. Thanks!

Ian @ un4seen

  • Administrator
  • Posts: 25866
Re: BASS for iOS (iPhone/iPad)
« Reply #1495 on: 9 Feb '24 - 13:59 »
In my case, Sustain is switched on, and then a note from a SF with a sample with infinite loop is played. That sound will be played continuously. When MIDI_EVENT_SOUNDOFF is triggered, instead of follow its envelope (that also is contained) until the sound is faded out, the sound keeps playing with no changes, like if the command was not sent (and it is returning true). In Android I do the same (the same SF, and the same commands and it is working as expected). I have tried with several SF2 files.

I guess you meant to write MIDI_EVENT_NOTESOFF rather than MIDI_EVENT_SOUNDOFF? Are you also switching sustain off sometime after that? No notes will be released until then. Individual note-off events (MIDI_EVENT_NOTE with vel=0) don't release notes when sustain is on, and MIDI_EVENT_NOTESOFF is a note-off event for all keys.

It's strange if you're seeing different results on iOS and Android, as the processing is basically the same on all platforms. Please confirm with BASS_MIDI_GetVersion that you're using the same version in both cases.

rrhh_fx

  • Posts: 39
Re: BASS for iOS (iPhone/iPad)
« Reply #1496 on: 9 Feb '24 - 14:16 »
In my case, Sustain is switched on, and then a note from a SF with a sample with infinite loop is played. That sound will be played continuously. When MIDI_EVENT_SOUNDOFF is triggered, instead of follow its envelope (that also is contained) until the sound is faded out, the sound keeps playing with no changes, like if the command was not sent (and it is returning true). In Android I do the same (the same SF, and the same commands and it is working as expected). I have tried with several SF2 files.

I guess you meant to write MIDI_EVENT_NOTESOFF rather than MIDI_EVENT_SOUNDOFF? Are you also switching sustain off sometime after that? No notes will be released until then. Individual note-off events (MIDI_EVENT_NOTE with vel=0) don't release notes when sustain is on, and MIDI_EVENT_NOTESOFF is a note-off event for all keys.

It's strange if you're seeing different results on iOS and Android, as the processing is basically the same on all platforms. Please confirm with BASS_MIDI_GetVersion that you're using the same version in both cases.

My apologies. I indeed meant to say MIDI_EVENT_NOTESOFF. If sustain is switched off after that, then the notes are released correctly. I understand your point about MIDI_EVENT_NOTESOFF, suggesting that actually the behavior on the Android version might not be working as expected. I will double-check the behavior on Android and confirm that the versions are the same before getting back to you. Thank you, Ian.