thatbakamono / bass-sys Goto Github PK
View Code? Open in Web Editor NEWFFI bindings for bass
License: MIT License
FFI bindings for bass
License: MIT License
As described in the title, the signatures of TagBext
, TagCart
, TagCue
and TagSample
are incorrect. These four structures use a mechanism called flexible array member, as you can see below:
typedef struct {
char Description[256]; // description
char Originator[32]; // name of the originator
char OriginatorReference[32]; // reference of the originator
char OriginationDate[10]; // date of creation (yyyy-mm-dd)
char OriginationTime[8]; // time of creation (hh-mm-ss)
QWORD TimeReference; // first sample count since midnight (little-endian)
WORD Version; // BWF version (little-endian)
BYTE UMID[64]; // SMPTE UMID
BYTE Reserved[190];
#if defined(__GNUC__) && __GNUC__<3
char CodingHistory[0]; // history
#elif 1 // change to 0 if compiler fails the following line
char CodingHistory[]; // history
#else
char CodingHistory[1]; // history
#endif
} TAG_BEXT;
typedef struct
{
char Version[4]; // version of the data structure
char Title[64]; // title of cart audio sequence
char Artist[64]; // artist or creator name
char CutID[64]; // cut number identification
char ClientID[64]; // client identification
char Category[64]; // category ID, PSA, NEWS, etc
char Classification[64]; // classification or auxiliary key
char OutCue[64]; // out cue text
char StartDate[10]; // yyyy-mm-dd
char StartTime[8]; // hh:mm:ss
char EndDate[10]; // yyyy-mm-dd
char EndTime[8]; // hh:mm:ss
char ProducerAppID[64]; // name of vendor or application
char ProducerAppVersion[64]; // version of producer application
char UserDef[64]; // user defined text
DWORD dwLevelReference; // sample value for 0 dB reference
TAG_CART_TIMER PostTimer[8]; // 8 time markers after head
char Reserved[276];
char URL[1024]; // uniform resource locator
#if defined(__GNUC__) && __GNUC__<3
char TagText[0]; // free form text for scripts or tags
#elif 1 // change to 0 if compiler fails the following line
char TagText[]; // free form text for scripts or tags
#else
char TagText[1]; // free form text for scripts or tags
#endif
typedef struct
{
DWORD dwCuePoints;
#if defined(__GNUC__) && __GNUC__<3
TAG_CUE_POINT CuePoints[0];
#elif 1 // change to 0 if compiler fails the following line
TAG_CUE_POINT CuePoints[];
#else
TAG_CUE_POINT CuePoints[1];
#endif
} TAG_CUE;
typedef struct
{
DWORD dwManufacturer;
DWORD dwProduct;
DWORD dwSamplePeriod;
DWORD dwMIDIUnityNote;
DWORD dwMIDIPitchFraction;
DWORD dwSMPTEFormat;
DWORD dwSMPTEOffset;
DWORD cSampleLoops;
DWORD cbSamplerData;
#if defined(__GNUC__) && __GNUC__<3
TAG_SMPL_LOOP SampleLoops[0];
#elif 1 // change to 0 if compiler fails the following line
TAG_SMPL_LOOP SampleLoops[];
#else
TAG_SMPL_LOOP SampleLoops[1];
#endif
} TAG_SMPL;
It was implemented in bass-sys code like that:
https://github.com/KernelErr0r/bass-sys/blob/be2537c57b771b6baddf323d33bf7f5582d908da/src/types.rs#L353-L365
https://github.com/KernelErr0r/bass-sys/blob/be2537c57b771b6baddf323d33bf7f5582d908da/src/types.rs#L411-L434
https://github.com/KernelErr0r/bass-sys/blob/be2537c57b771b6baddf323d33bf7f5582d908da/src/types.rs#L515-L520
https://github.com/KernelErr0r/bass-sys/blob/be2537c57b771b6baddf323d33bf7f5582d908da/src/types.rs#L562-L575
and that's plain wrong. FAM doesn't provide length and even if it did, I wouldn't bet my life on rustc and Rust's inner implementation of Vec.
There is an RFC for dealing with these kinds of situations easily but unfortunately, it's just an RFC, it isn't a part of Rust.
I found a working way of doing that, it makes use of ZST to represent FAM and encapsulates everything in a Box-like wrapper struct to provide a nice API to deal with FAM, unfortunately, it comes with its own issues, you can see it described in details here.
// As a side note: I could also use ZST to represent FAM and leave everything else to the user, it kinda makes sense because these are pure FFI bindings and I shouldn't put any abstraction here, but I don't want to make the user deal with this stupid shit.
Types with flexible array members, just like this, this, this, and this derive the Clone
trait, which won't work correctly.
i'm getting a panic when trying to set params like this
self.fx = bass_sys::BASS_ChannelSetFX(self.stream, bass_sys::BASS_FX_VOLUME, 0);
let gain = 10_f64.powf(song.track_gain / 20.0);
// pub struct BassFxVolumeParam {
// pub target: f32,
// pub current: f32,
// pub time: f32,
// pub curve: DWORD,
// }
println!("Gain: {}", gain);
let params = bass_sys::BassFxVolumeParam {
target: gain as f32,
current: 0.0,
time: 0.0,
curve: 0,
};
println!("params: {:?}", params);
println!("fx: {:?}", self.fx);
let fxset = bass_sys::BASS_FxSetParameters(
self.fx,
¶ms as *const bass_sys::BassFxVolumeParam as *const c_void,
);
the error is
thread 'main' panicked at 'Failed to load the function.', /Users/<redacted>/.cargo/registry/src/github.com-1ecc6299db9ec823/bass-sys-2.2.2/src/functions.rs:90:1
any idea on how to fix it ?
makes it a bit hard to actually use devices :P
Tks this crate.
msvc x86 compile link error output like:
error LNK2019: 无法解析的外部符号 _BASS_Free,函数 __ZN53_$LT$bass..TBass$u20$as$u20$core..ops..drop..Drop$GT$4drop17h3
5a3f4d22b8c34e6E 中引用了该符号
error LNK2019: 无法解析的外部符号 _BASS_GetVersion,函数 __ZN4bass5TBass3new17hc4ec67e87fa95898E 中引用了该符号
function should exterm system。
The library is missing BASS_Mix bindings
Is it just a matter of adding
binding BASS_MIXER_STREAMCREATE fn BASS_Mixer_StreamCreate(
frequency: DWORD,
channels: DWORD,
flags: DWORD,
proc: *mut STREAMPROC,
user: *mut c_void
) -> HSTREAM;
? if so I can try to help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.