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

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1175 on: 31 Mar '17 - 15:07 »
The iOS version of the BASSMIDI 2.4.11 release is now up in the 1st post.

draenorr

  • Posts: 2
Re: BASS for iOS (iPhone/iPad)
« Reply #1176 on: 3 Apr '17 - 09:24 »
Hello, I have a problem with bitRate
I'm trying to open online stream
http://radio.sosimc.ru:9000/838264aac
Code: [Select]
BASS_ChannelGetAttribute(chan, BASS_ATTRIB_BITRATE, &_bitRate)bass return me 4294967

This value returned for any AAC stream. Is this attribute unsupported for AAC or I'm made an error somewhere?
« Last Edit: 3 Apr '17 - 09:59 by draenorr »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1177 on: 3 Apr '17 - 15:55 »
A BASS update to fix that problem is up now in the 1st post, so please re-download to get that.

draenorr

  • Posts: 2
Re: BASS for iOS (iPhone/iPad)
« Reply #1178 on: 4 Apr '17 - 08:59 »
Thank you very much!

Oleg N

  • Posts: 86
BASS_StreamCreateURL() for iTunes music delay
« Reply #1179 on: 7 Apr '17 - 11:57 »
Has anyone had this problem?
When starting a track on iOS device from iTunes library using "ipod-library://" URL it takes 2 to 7 seconds before playback actually starts.
- tracks are usually 320 kbps AAC, without DRM, synced from iTunes on mac.
- reproduces randomly on iPhone 5S, 6S, 7+, with iOS 10.3, built on XCode 8;
- no particular track on which this happens, problem seems to disappear after 3-4 tracks, but then suddenly sometimes appears again

Code: [Select]
    DWORD flags = BASS_SAMPLE_FLOAT | BASS_ASYNCFILE;
    _sourceChannel = BASS_StreamCreateURL(iPodURL.absoluteString.UTF8String, 0, flags, NULL, NULL);
« Last Edit: 7 Apr '17 - 16:50 by Oleg N »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1180 on: 7 Apr '17 - 16:01 »
Is the delay in the stream creation or in starting playback, ie. in the BASS_StreamCreateURL or BASS_ChannelPlay call?

With "ipod-library://" URLs, iOS (rather than BASS) handles the file reading. I'm not entirely sure what iOS does internally with them, eg. what sort of overhead iPod library access has.

Oleg N

  • Posts: 86
Re: BASS for iOS (iPhone/iPad)
« Reply #1181 on: 4 May '17 - 09:47 »
Quote

Is the delay in the stream creation or in starting playback, ie. in the BASS_StreamCreateURL or BASS_ChannelPlay call?

With "ipod-library://" URLs, iOS (rather than BASS) handles the file reading. I'm not entirely sure what iOS does internally with them, eg. what sort of overhead iPod library access has.


Ian, I switched to using our own plugin for iPod-library URLs and problem is gone. My plugin uses AudioFile and ExtAudioFile as appropriate. Standart   BASS_StreamCreateURL seems to spend some time on locked background thread when executing BASS_StreamCreateURL(). That could be partially because once stream is created, I am often creating the second temporary stream with the same url, for analysis, and Apple documented these API as not thread - safe. So actually not BASS problem, but maybe the point for improvement.
« Last Edit: 4 May '17 - 09:50 by Oleg N »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1182 on: 4 May '17 - 16:53 »
BASS uses AudioFile and ExtAudioFile too when dealing with "ipod-library://" URLs, but perhaps it's doing something different to what you did. I will send you a debug version to try to locate where the delay is coming from.

Oleg N

  • Posts: 86
Re: BASS for iOS (iPhone/iPad)
« Reply #1183 on: 9 May '17 - 17:10 »
Turns out, using up-to-date BASS lib build solved my problem with delay on ipod-library resources. Thank You, Ian!

StephBel

  • Posts: 7
Re: BASS for iOS (iPhone/iPad)
« Reply #1184 on: 17 May '17 - 10:51 »
Hello,
Apple now reject App that are listening to device lock notifications.
I can't spot with 3rd party library is making my App rejected  :(
Does BASS use com.apple.springboard.lockstate ?


Spotted, you are not the bad guy  ;D
« Last Edit: 17 May '17 - 11:00 by StephBel »

Oleg N

  • Posts: 86
Re: BASS for iOS (iPhone/iPad)
« Reply #1185 on: 18 May '17 - 13:10 »
Hello,
Apple now reject App that are listening to device lock notifications.

Wow... Did You have this string somewhere in the code (com.apple.springboard.lockstate)? Or can they detect the fact of app listening to Springboard even if it's not simply hardcoded in?
« Last Edit: 18 May '17 - 13:29 by Oleg N »

StephBel

  • Posts: 7
Re: BASS for iOS (iPhone/iPad)
« Reply #1186 on: 19 May '17 - 07:52 »
Yes, I made a grep and a 3rd party library was registering an observer on "com.apple.springboard.lockstate".
I think Apple is looking for the string because my App binary was rejected just after the submission.

Oleg N

  • Posts: 86
Re: BASS for iOS (iPhone/iPad)
« Reply #1187 on: 13 Jun '17 - 15:57 »
So, anyone had a chance to couple BASS with new Airplay2 AVSampleBufferAudioRenderer / AVSampleBufferRenderSynchronizer capability already? seems like an answer to 3-year Airplay dis-functionality for multiple devices support...

https://devstreaming-cdn.apple.com/videos/wwdc/2017/509v96e4gd96rlqyq/509/509_introducing_airplay_2.pdf
(from page 61)

Ge0rges

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1188 on: 9 Jul '17 - 00:01 »
Hi, How can I get notified by BASS when my channel created with BASS_StreamCreateFile has finished playing the file?

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1189 on: 10 Jul '17 - 17:16 »
You can set a BASS_SYNC_END sync via BASS_ChannelSetSync to get notified when playback reaches the end, something like this:

Code: [Select]
BASS_ChannelSetSync(stream, BASS_SYNC_END, 0, EndSyncProc, NULL);
BASS_ChannelPlay(stream, 0);

...

void EndSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
// do something here
}

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1190 on: 31 Jul '17 - 14:32 »
Hi,

I am having some issues with the latest version of BASS in iOS 10.

Basically, BASS is randomly unable to detect a plugged in MIDI keyboard (we have tried several models). Sometimes it just works perfectly, but others the keyboard is never detected, no matter how many times you plug or unplug.

Here is the code for initialising the device:

Code: [Select]
   int dev;
    for (dev=0;BASS_MIDI_InGetDeviceInfo(dev,&_bassInputDeviceInfo);dev++) {
    }
    if (dev) {
        int a;
        for (a=0;a<dev;a++) {
            BASS_MIDI_DEVICEINFO info;
            BASS_MIDI_InGetDeviceInfo(a,&info);
            NSString * deviceName = [NSString stringWithCString:info.name encoding:NSASCIIStringEncoding];
            if (info.flags & BASS_DEVICE_ENABLED){ // session 1 is Core Midi network port?
                if (BASS_MIDI_InInit(a,MidiInProc,(__bridge void *)(self))) {
                    _bassMidiInputDevice=a;
                    BASS_MIDI_InStart(_bassMidiInputDevice);
                    _bassInputDeviceInfo=info;
                    break;
                }
            }
        }
    }

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1191 on: 1 Aug '17 - 15:41 »
Is the MIDI device missing from the BASS_MIDI_InGetDeviceInfo list, or is the BASS_DEVICE_ENABLED flag missing from it, or is the BASS_MIDI_InInit call failing? If you are re-enumerating the MIDI devices, how long are you waiting between each enumeration cycle? BASSMIDI will only re-enumerate the MIDI devices up to once per second, so you would need to have at least a 1 second gap to see different results.

Are you only having the problem with BASSMIDI, never with any other apps?

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1192 on: 1 Aug '17 - 19:57 »
The device is missing from the BASS_MIDI_InGetDeviceInfo list (no devices are listed).

I am continuously checking for devices every 200ms (checking if new devices are in, checking if old devices are disabled, etc.). Good to know that the reenumeration happens once per second.

I am developing a single app that makes extensive use of BASSMIDI, so I cannot tell if the problem happens with other apps.

Some more info:

1. It seems that if you plug in the keyboard BEFORE starting the app, then it will always be enumerated.
2. I have seen this ill behaviour in iPad Pro only, while not in an old 32-bit iPad (both are running iOS 10.3.3)

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1193 on: 2 Aug '17 - 14:32 »
Google suggests that this may be a bug in the OS, where it is apparently caching the initially detected MIDI devices and not refreshing that information until the app is reloaded. Strange though that you're having the problem with one device and not another with the same iOS version installed. What do you see if you poll MIDIGetNumberOfDevices and MIDIGetNumberOfSources when adding/removing a MIDI input device? One suggestion I saw was making sure the enumeration calls are done in the main thread (not a worker thread), so you could try that if you aren't already.

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1194 on: 2 Aug '17 - 14:54 »
When the problem happens, I see:

BASS_MIDI_InGetDeviceInfo count: 0
MIDIGetNumberOfDevices: 3
MIDIGetNumberOfSources: 0

And this does not change no matter how many times you plug or unplug.

I am already making all the calls in the main thread.

Does this help?

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1195 on: 2 Aug '17 - 17:21 »
If the numbers are never changing when (un)plugging the MIDI device, that would seem to confirm that the MIDI devices are only being enumerated once by iOS. I guess the numbers above were from when the MIDI device was not plugged in beforehand? What do you see if it is plugged in? Do you see the numbers changing on the old iPad?

Can you try some MIDI apps from the app store and see if you have the same problem with them?

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1196 on: 2 Aug '17 - 21:04 »
Yes, the numbers above are from when the MIDI device was NOT plugged in beforehand.

I see, when the keyboard is plugged in beforehand:

BASS_MIDI_InGetDeviceInfo count: 1
MIDIGetNumberOfDevices: 3
MIDIGetNumberOfSources: 1

which makes sense.

I see the numbers changing if (un)plugging the device. Namely, MidiGetNumberOfSources changes from 1 to 0 and back to 1 (as expected I guess).

This also happens in the old iPad.

However, I have tried GarageBand and Home Concert and they DO NOT have this problem. The device is always detected even if plugged in after starting the app. This happens on both iPads.

So... there is something fishy here.

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: BASS for iOS (iPhone/iPad)
« Reply #1197 on: 3 Aug '17 - 16:51 »
Yes, the numbers above are from when the MIDI device was NOT plugged in beforehand.

I see, when the keyboard is plugged in beforehand:

BASS_MIDI_InGetDeviceInfo count: 1
MIDIGetNumberOfDevices: 3
MIDIGetNumberOfSources: 1

which makes sense.

I see the numbers changing if (un)plugging the device. Namely, MidiGetNumberOfSources changes from 1 to 0 and back to 1 (as expected I guess).

This also happens in the old iPad.

OK. So MIDI device enumeration works fine on both of your iPads so long as the MIDI device is plugged in before starting the app, and it works fine on the old iPad even if the MIDI device isn't plugged in first?

However, I have tried GarageBand and Home Concert and they DO NOT have this problem. The device is always detected even if plugged in after starting the app. This happens on both iPads.

So... there is something fishy here.

That's strange. Perhaps they are enumerating MIDI devices in a different way (I'll try to find out if there is another way), or perhaps the device enumeration is just delayed? Do they detect when the MIDI device is unplugged (after it has been detected) and another one is plugged in?

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1198 on: 3 Aug '17 - 19:08 »
"OK. So MIDI device enumeration works fine on both of your iPads so long as the MIDI device is plugged in before starting the app, and it works fine on the old iPad even if the MIDI device isn't plugged in first?"

That is correct

"That's strange. Perhaps they are enumerating MIDI devices in a different way (I'll try to find out if there is another way), or perhaps the device enumeration is just delayed? Do they detect when the MIDI device is unplugged (after it has been detected) and another one is plugged in?"

Right now, I cannot test with different devices. I only have one keyboard here. But I can tell you about this on Tuesday.

Thanks

AldoIlsant

  • Guest
Re: BASS for iOS (iPhone/iPad)
« Reply #1199 on: 4 Aug '17 - 12:59 »
UPDATE: it seems the issue IS FIXED if the following conditions meet:

1. You call Bass_Init on the main thread (I was missing this part, I was calling it from a global queue).
2. You call all the enumeration methods on the main thread (as you suggested).

Thanks! This is a great relief. But please add to the documentation!