migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
985 stars 55 forks source link

AudioStreamPlayback missing `_mix` method in bindings #501

Closed LemmaEOF closed 1 week ago

LemmaEOF commented 2 weeks ago

Describe the bug AudioStreamPlayback has a _mix method that is defined in extension_api.json but is not exposed to SwiftGodot. The extension description is as follows:

{
    "name": "_mix",
    "is_const": false,
    "is_static": false,
    "is_vararg": false,
    "is_virtual": true,
    "return_value": {
        "type": "int",
        "meta": "int32"
    },
    "arguments": [
        {
            "name": "buffer",
            "type": "AudioFrame*"
        },
        {
            "name": "rate_scale",
            "type": "float",
            "meta": "float"
        },
        {
            "name": "frames",
            "type": "int",
            "meta": "int32"
        }
    ],
    "description": ""
},

The buffer argument's AudioFrame* type is an array that is modified as a side-effect of the operation, so it will need to be an inout [AudioFrame] in the Swift type signature. This is critical for tasks like processing audio for visualization, and its exclusion makes those currently impossible.

migueldeicaza commented 1 week ago

This is a variation of the pending work for #13

I have for now surfaced the AudioFrame structure, but also the API with a "OpaquePointer", which you will need to cast into AudioFrame* (something like UnsafeMutableBufferPointer) with both the OpaquePointer and the count value.