Converting DSD to PCM with BASS_ChannelGetData

Started by soundgals, 24 Feb '24 - 14:56

Ian @ un4seen

Quote from: soundgals on 21 Mar '24 - 10:29The error text...

"Cannot convert value of type '(UInt32, UInt32, UnsafeRawPointer?, UInt32, UInt64, UnsafeMutableRawPointer?) -> Void'
 to expected argument type
'(@convention(c) (HENCODE, DWORD, UnsafeRawPointer?, DWORD, UnsafeMutableRawPointer?) -> Void)?'
(aka 'Optional<@convention(c) (UInt32, UInt32, Optional<UnsafeRawPointer>, UInt32, Optional<UnsafeMutableRawPointer>) -> ()>')"

... indicates to me that the offset parameter UInt64, is still not being expected by the call to BASS_Encode_StartLimit.

Yes, you will need to typecast the ENCODEPROCEX callback to an ENCODEPROC in the BASS_Encode_Start(Limit) call, or add an ENCODEPROCEX overload to the BASSenc header. That could look like this:

static inline HENCODE BASS_Encode_Start(DWORD handle, const char *cmdline, DWORD flags, ENCODEPROCEX *proc, void *user)
{
return BASS_Encode_Start(handle, cmdline, flags | BASS_ENCODE_PROCEX, (ENCODEPROC*)proc, user);
}

Btw, with an ENCODEPROCEX callback, the headers can be updated so there's no need to tell the amount of data in advance via BASS_Encode_StartLimit. You can simply use BASS_Encode_Start.

soundgals

Thanks Ian. I just tried adding that code to the bassenc.h header, as I thought that would be the easier option.

Unfortunately it didn't get rid of the xCode error though. I cleaned the Product folder in between to make sure I started fresh.

I also changed BASS_Encode_StartLimit to BASS_Encode_Start and deleted the limit parameter.

Do I still need to make that typecast?

Ian @ un4seen

Where exactly in the bassenc.h header did you add the overload? If it's at the bottom, where the others are, then note that those are only enabled when "__cplusplus" and "_WIN32" are defined. I don't know if Swift defines "__cplusplus" but it definitely won't define "_WIN32". So if that is where it currently is, try moving it out of that #if block. If doing that doesn't help, to confirm that Xcode is using your modified header, try adding some rubbish to it and see if Xcode complains about that.

soundgals

Ok I moved it outside of the #ifdef _WIN32, to outside of any #ifdef block. Also tried it within the __cplusplus block. Whichever place I put it that didn't generate an error within the header, I still got the xCode error in my code.

I added rubbish, because I placed it in an invalid place at one point and xCode complained within the header file.

Ian @ un4seen

If you have no luck with overloads or typecasting then another option is to just change the standard BASS_Encode_Start function declaration in BASSENC.H to take an ENCODEPROCEX instead of ENCODEPROC. You wouldn't be able to use ENCODEPROCs then but it doesn't seem like you need to anyway.

soundgals

Thanks Ian. That got rid of the xCode errors. I will test later to ensure I get the data equivalent of a playable WAV file.

soundgals

Just carried out that test and it's working great! Thanks again Ian.