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

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1375 on: 10 Aug '20 - 14:40 »
Those missing symbols are in the Accelerate framework, so adding that to the project should fix it.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1376 on: 10 Aug '20 - 19:46 »
Those missing symbols are in the Accelerate framework, so adding that to the project should fix it.

Thank you Ian. I'll check that ASAP.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1377 on: 11 Aug '20 - 15:06 »
Those missing symbols are in the Accelerate framework, so adding that to the project should fix it.

Hi Ian. I was able to get it working in Unity! Attached is some code people might want.

Code: [Select]
public class BuildAutomation : MonoBehaviour, IPostprocessBuildWithReport
{
    //POSTPROCESSOR
    public void OnPostprocessBuild(BuildReport report)
    {
        string path = report.summary.outputPath;
        Debug.Log($"path: {path}");

#if UNITY_IPHONE
        string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        var pbxProject = new UnityEditor.iOS.Xcode.PBXProject();
        pbxProject.ReadFromFile(projectPath);

        //TODO: Make request with BASS.NET to enable bitcode
        //within their ios libs

        //The unity project
        string target = pbxProject.GetUnityMainTargetGuid();
        pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

        //the unity framework
        string targetFramework = pbxProject.GetUnityFrameworkTargetGuid();
        pbxProject.SetBuildProperty(targetFramework, "ENABLE_BITCODE", "NO");

        //Required by bass.net and sublibraries
        //AudioToolbox, SystemConfiguration, CFNetwork, Accelerate, CoreMIDI
        pbxProject.AddFrameworkToProject(targetFramework, "AudioToolbox.framework", true);
        pbxProject.AddFrameworkToProject(targetFramework, "SystemConfiguration.framework", true);
        pbxProject.AddFrameworkToProject(targetFramework, "CFNetwork.framework", true);
        pbxProject.AddFrameworkToProject(targetFramework, "Accelerate.framework", true);
        pbxProject.AddFrameworkToProject(targetFramework, "CoreMIDI.framework", true);

        pbxProject.WriteToFile(projectPath);
#endif
    }

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1378 on: 11 Aug '20 - 16:24 »
Great! Hopefully other Unity users with find that helpful.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1379 on: 11 Aug '20 - 21:26 »
For some reason when I run on macOS (and others) I'm getting BASS_ERROR_ILLTYPE with BASS_ChannelSetFX. I'm sending it the stream handle from a net radio stream, which is working fine in the Unity Editor but failing in the IL2CPP compiled version.

I don't understand why it's an ILLTYPE here unless maybe the type is being stripped.

BASS_ChannelSetFX error code BASS_ERROR_ILLTYPE.

Code: [Select]
public void AddEffect(int stream)
{
    try
    {
        if (stream == 0)
        {
            Debug.Log("unable to apply filter to stream 0");
            return;
        }

        //Old deprecated effect
        BASS_BFX_LPF lpf = new BASS_BFX_LPF(2f, 300f, BASSFXChan.BASS_BFX_CHANALL);

        //new efect to use
        //var lpf = new BASS_BFX_BQF(BASSBFXBQF.BASS_BFX_BQF_LOWPASS, 300f, 0f, 0f, 0f, 0f, BASSFXChan.BASS_BFX_CHANALL);

        filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_LPF, 1);
        if(filterHandle == 0)
        {
            //It's failing here
            Debug.LogError($"BASS_ChannelSetFX error code {Bass.BASS_ErrorGetCode()}");
            return;
        }

        bool success = Bass.BASS_FXSetParameters(filterHandle, lpf);
        if(!success)
        {
            Debug.LogError($"BASS_FXSetParameters error code {Bass.BASS_ErrorGetCode()}");
        }
    }
    catch(Exception ex)
    {
        Debug.LogError(ex.Message + ex.StackTrace);
    }
}
« Last Edit: 11 Aug '20 - 22:12 by zippo227 »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1380 on: 12 Aug '20 - 17:13 »
BASS_ChannelSetFX error code BASS_ERROR_ILLTYPE.

That means the BASS_ChannelSetFX "type" parameter wasn't recognised. When trying to use a BASS_FX effect (as above), it's caused by the BASS_FX library not being loaded. .Net loads libraries when they're first used, so you can force it to load the BASS_FX library in advance by calling a BASS_FX function, eg. BASS_FX_GetVersion in your initialization code.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1381 on: 12 Aug '20 - 17:35 »
BASS_ChannelSetFX error code BASS_ERROR_ILLTYPE.

That means the BASS_ChannelSetFX "type" parameter wasn't recognised. When trying to use a BASS_FX effect (as above), it's caused by the BASS_FX library not being loaded. .Net loads libraries when they're first used, so you can force it to load the BASS_FX library in advance by calling a BASS_FX function, eg. BASS_FX_GetVersion in your initialization code.

I knew it had to be something like that because it sometimes did work. Thanks Ian! I'll test ASAP.

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1382 on: 12 Aug '20 - 18:31 »
I added this code, and it seems to help.

Code: [Select]
//Now load up the other libraries to ensure they're in memory
int bassVer = Bass.BASS_GetVersion();
int bassFxVer = BassFx.BASS_FX_GetVersion();
int bassEncVer = BassEnc.BASS_Encode_GetVersion();
int bassMixVer = BassMix.BASS_Mixer_GetVersion();

Debug.Log($"Bass Lib Versions. bassVer:{bassVer} bassFxVer:{bassFxVer} Bass:{bassEncVer} Bass:{bassMixVer}");

The low pass filter effect I'm adding is audible, however I'm seeing this error in the log.

Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.Effects.LowPassFilterEffect.AddEffect (System.Int32 stream) [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.IceListener.BufferStreamAndPlay () [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.IceListener.PlayThread () [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1383 on: 13 Aug '20 - 17:19 »
I'm not a .Net user myself, so I'm not sure, but that looks like it had a problem with the parameters in a BASS_FXSetParameters call. Can you post that code?

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1384 on: 13 Aug '20 - 17:42 »
I'm not a .Net user myself, so I'm not sure, but that looks like it had a problem with the parameters in a BASS_FXSetParameters call. Can you post that code?

Hi Ian. It's the call BASS_FXSetParameters  from my previous post that is throwing an exception. Originally, it was failing at BASS_ChannelSetFX, but now that I'm loading the libraries ahead of time, that is working fine. Here's the code again with an updated comment in the section that's reporting the error.

Code: [Select]
//Storing this variable in the class to increase the reference count
BASS_BFX_LPF lpf;

public void AddEffect(int stream)
{
    try
    {
        if (stream == 0)
        {
            Debug.Log("unable to apply filter to stream 0");
            return;
        }

        lpf = new BASS_BFX_LPF(2f, 300f, BASSFXChan.BASS_BFX_CHANALL);

        filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_LPF, 1);
        if(filterHandle == 0)
        {
            Debug.LogError($"BASS_ChannelSetFX error code {Bass.BASS_ErrorGetCode()}");
            return;
        }

        //It's failing here with: Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
        bool success = Bass.BASS_FXSetParameters(filterHandle, lpf);
        if(!success)
        {
            Debug.LogError($"BASS_FXSetParameters error code {Bass.BASS_ErrorGetCode()}");
        }
    }
    catch(Exception ex)
    {
        Debug.LogError(ex.Message + ex.StackTrace);
    }
}

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1385 on: 13 Aug '20 - 18:06 »
I don't think the parameter structure (lpf) needs to be global, so you could try moving that into the function and see if that makes any difference:

Code: [Select]
BASS_BFX_LPF lpf = new BASS_BFX_LPF(2f, 300f, BASSFXChan.BASS_BFX_CHANALL);

If the problem still happens, for comparison, what happens if you instead try using one of BASS's built-in effects, eg. BASS_FX_DX8_PARAMEQ?

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1386 on: 13 Aug '20 - 18:47 »
I don't think the parameter structure (lpf) needs to be global, so you could try moving that into the function and see if that makes any difference:

Code: [Select]
BASS_BFX_LPF lpf = new BASS_BFX_LPF(2f, 300f, BASSFXChan.BASS_BFX_CHANALL);

If the problem still happens, for comparison, what happens if you instead try using one of BASS's built-in effects, eg. BASS_FX_DX8_PARAMEQ?

HI Ian. I tried making the parameter structure local and then tried switching to a built-in effect as suggested. Similar issue, except now it's throwing the exception within BASS_FXGetParametersExt . Is there some kind of premarashling I can do for the object?

Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXGetParametersExt (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
  at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.Effects.LowPassFilterEffect.AddEffect (System.Int32 stream) [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.IceListener.BufferStreamAndPlay () [0x00000] in <00000000000000000000000000000000>:0
  at Consortya.AudioTools.IceListener.PlayThread () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Consortya.AudioTools.Effects.LowPassFilterEffect:AddEffect(Int32)
Consortya.AudioTools.IceListener:BufferStreamAndPlay()
Consortya.AudioTools.IceListener:PlayThread()
UnityEngine.Events.UnityAction:Invoke()
System.Threading.ParameterizedThreadStart:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
UnityEngine.Events.UnityAction:Invoke()


Code: [Select]
public void AddEffect(int stream)
{
try
{
if (stream == 0)
{
Debug.Log("unable to apply filter to stream 0");
return;
}

RemoveEffect(stream);

var eq = new BASS_DX8_PARAMEQ();
filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 1);

if (filterHandle == 0)
{
Debug.LogError($"BASS_ChannelSetFX error code {Bass.BASS_ErrorGetCode()}");
return;
}

bool success = Bass.BASS_FXSetParameters(filterHandle, eq);
if(!success)
{
Debug.LogError($"BASS_FXSetParameters error code {Bass.BASS_ErrorGetCode()}");
}
}
catch(Exception ex)
{
Debug.LogError(ex.Message + ex.StackTrace);
}
}
« Last Edit: 13 Aug '20 - 21:34 by zippo227 »

radio42

  • Posts: 4839
Re: BASS for iOS (iPhone/iPad)
« Reply #1387 on: 14 Aug '20 - 21:23 »
The class BASS_BFX_LPF is actually marked as "Obsolete" in the BassFX add-on - I guess this is why?!
Maybe is has already been removed from BassFX?

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1388 on: 14 Aug '20 - 21:26 »
The class BASS_BFX_LPF is actually marked as "Obsolete" in the BassFX add-on - I guess this is why?!
Maybe is has already been removed from BassFX?

I tried it with non obsolete BQF method and the method you recommended. Same issue for each thing.

radio42

  • Posts: 4839
Re: BASS for iOS (iPhone/iPad)
« Reply #1389 on: 17 Aug '20 - 14:14 »
What .Net Framework and what BASS.NET version is the user using?!

If you are on iOS, you should use the BASS.NET.iOS.dll ?!

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1390 on: 17 Aug '20 - 15:10 »
What .Net Framework and what BASS.NET version is the user using?!

If you are on iOS, you should use the BASS.NET.iOS.dll ?!

Hi Ian. I'm using Bass.Net.iOS.dll  2.4.14.1 with .net standard 2.0

radio42

  • Posts: 4839
Re: BASS for iOS (iPhone/iPad)
« Reply #1391 on: 19 Aug '20 - 17:13 »
Can you confirm, that you are really using this overload with your BASS_FXGetParameters method call?!
(again, the BASS_BFX_LPF is obsolete and not supported any longer)

Code: [Select]
public static extern bool BASS_FXGetParameters(int handle, [In, Out]AddOn.Fx.BASS_BFX_BQF par);

zippo227

  • Posts: 57
Re: BASS for iOS (iPhone/iPad)
« Reply #1392 on: 19 Aug '20 - 18:30 »
Can you confirm, that you are really using this overload with your BASS_FXGetParameters method call?!
(again, the BASS_BFX_LPF is obsolete and not supported any longer)

Code: [Select]
public static extern bool BASS_FXGetParameters(int handle, [In, Out]AddOn.Fx.BASS_BFX_BQF par);

Seems like the only path forward is for me to make a sample project that shows this bug in the github repo I set up. That will take me some time though. Maybe I can have it ready this week.

I'm not calling BASS_FXGetParameters but rather BASS_FXSetParameters.


Code is below

Code: [Select]
public void AddEffect(int stream)
{
    try
    {
        if (stream == 0)
        {
            Debug.Log("unable to apply filter to stream 0");
            return;
        }

        RemoveEffect(stream);

        BASS_BFX_BQF lpf = new BASS_BFX_BQF(BASSBFXBQF.BASS_BFX_BQF_LOWPASS, 300f, 0f, 0f, 0f, 0f, BASSFXChan.BASS_BFX_CHANALL);
        filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_BQF, 1);

        if (filterHandle == 0)
        {
            Debug.LogError($"BASS_ChannelSetFX error code: {Bass.BASS_ErrorGetCode()}");
            return;
        }

        bool success = Bass.BASS_FXSetParameters(filterHandle, lpf);
        if(!success)
        {
            Debug.LogError($"BASS_FXSetParameters error code: {Bass.BASS_ErrorGetCode()}");
        }
    }
    catch(Exception ex)
    {
        Debug.LogError(ex.Message + ex.StackTrace);
    }
}


radio42

  • Posts: 4839
Re: BASS for iOS (iPhone/iPad)
« Reply #1393 on: 19 Aug '20 - 19:20 »
I am sorry, but in your above post, the error message is:
Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXGetParametersExt (...

That's why I was asking?!

But the same would apply the the other error above, which says:
Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
Here I would ask:
Are you sure to use the following overload:
public static extern bool BASS_FXSetParameters(int handle, [In, Out]AddOn.Fx.BASS_BFX_BQF par);

Your code screen-shot indicates, yes, you are doing that!
If so, I assume you can NOT get any error message which you posted and all shoud work fine!
Can you confirm this?!

Note, your error message was:
Cannot marshal type 'System.Object'.  at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0

Spot the 'Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par)'.
There you used the object overload, but not the BASS_BFX_BQF.

So there seems to be something wrong with your tests?!

filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_LPF, 1);

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1394 on: 3 Sep '20 - 15:48 »
The iOS version of the BASSWV 2.4.7 release is up now in the 1st post.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1395 on: 17 Sep '20 - 17:29 »
The iOS version of the BASSMIDI 2.4.13 release is up now in the 1st post.

Ankit

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1396 on: 16 Oct '20 - 12:03 »
I am trying to load "BASSFLACplugin, BASSWVplugin" in Xcode Version 11.7 but getting this error:
"Variable has incomplete type 'void'"
My Code is:
extern void BASSFLACplugin, BASSWVplugin;
    BASS_PluginLoad(&BASSFLACplugin, 0);
    BASS_PluginLoad(&BASSWVplugin, 0);

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS for iOS (iPhone/iPad)
« Reply #1397 on: 16 Oct '20 - 14:13 »
That's strange. What type of source file is that code in, eg. Objective-C, or C, or C++? Anyway, you could try this modification:

Code: [Select]
void BASSFLACplugin(), BASSWVplugin();
BASS_PluginLoad((char*)BASSFLACplugin, 0);
BASS_PluginLoad((char*)BASSWVplugin, 0);

ankitsaini

  • Posts: 3
Re: BASS for iOS (iPhone/iPad)
« Reply #1398 on: 5 Nov '20 - 09:06 »
That's strange. What type of source file is that code in, eg. Objective-C, or C, or C++? Anyway, you could try this modification:

Code: [Select]
void BASSFLACplugin(), BASSWVplugin();
BASS_PluginLoad((char*)BASSFLACplugin, 0);
BASS_PluginLoad((char*)BASSWVplugin, 0);

I am using this code in objective c++ and my file extension is "ViewController.mm".

ankitsaini

  • Posts: 3
Re: BASS for iOS (iPhone/iPad)
« Reply #1399 on: 5 Nov '20 - 09:14 »
In IOS .mov or .mp4 audio files are not getting played. I am using below code to create stream file from audio file url.

_channel = BASS_StreamCreateURL([[url absoluteString] UTF8String], 0, BASS_SAMPLE_FLOAT|BASS_STREAM_PRESCAN|BASS_STREAM_DECODE, NULL, 0);

OR

_channel = BASS_StreamCreateFile(FALSE, [[url path] cStringUsingEncoding:NSUTF8StringEncoding], BASS_STREAM_PRESCAN , 0, BASS_SAMPLE_FLOAT|BASS_STREAM_PRESCAN|BASS_STREAM_DECODE);

I have the file stores locally in the bundle so no need of http request.

Any Idea what changes I need to implement in order to play above extensions.