{"id":18838063,"url":"https://github.com/labsound/labsound-c","last_synced_at":"2025-06-16T07:04:58.637Z","repository":{"id":150448645,"uuid":"447875150","full_name":"LabSound/labsound-c","owner":"LabSound","description":"C bindings for LabSound","archived":false,"fork":false,"pushed_at":"2024-10-07T06:37:18.000Z","size":424,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2024-12-30T08:44:33.068Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LabSound.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-14T07:11:54.000Z","updated_at":"2024-10-07T06:37:22.000Z","dependencies_parsed_at":"2024-12-30T08:43:55.258Z","dependency_job_id":"3aa8711b-b398-495f-b855-0dc316b8990b","html_url":"https://github.com/LabSound/labsound-c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LabSound%2Flabsound-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LabSound%2Flabsound-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LabSound%2Flabsound-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LabSound%2Flabsound-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LabSound","download_url":"https://codeload.github.com/LabSound/labsound-c/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239774337,"owners_count":19694700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T02:37:50.059Z","updated_at":"2025-02-20T04:15:24.177Z","avatar_url":"https://github.com/LabSound.png","language":"C","readme":"# LabSound C bindings\n\nThese C bindings are compatible with top of tree LabSound.\n\nThe beginnings of a Python wrapper is included, but not\nyet compiling. Help welcome :)\n\ncopyright (c) 2022- Nick Porcino\nMIT License\n\n## Getting Started\n\nTo build the bindings and demo with an existing LabSound installation, set\n`-DCMAKE_SYSTEM_PREFIX=/path/to/installRoot`. If this path is not provided,\nthe build will automatically fetch LabSound.\n\nTo use the bindings in your own project, include labsound-c.cpp into your \nproject directly, and also link to libnyquist and LabSound.\n\n## Interface\n\nAlthough labsound-c.cpp is implemented in C++, the interface in labsound-c.h \nexposes symbols for C.\n\nStrings are supplied to labsound-c via string slices. These are compatible with\nall languages you are likely to bind LabSound to, as there is no requirement \nthat the string be zero terminated.\n\n```c\ntypedef struct {\n    const char* start;\n    const char* end;\n} ls_StringSlice;\n```\n\nThere's an array of string slices ~\n\n```c\ntypedef struct {\n    ls_StringSlice* names;\n    int count;\n} ls_NameArray;\n```\n\nFor cstd users, there is a convenience function ~ \n\n```c\n#define ls_cstr(s) ls_StringSlice { (s), strlen(s) }\n```\n\nTime is passed in a simple struct to force a descriptive type ~\n\n```c\ntypedef struct {\n    float t;\n} ls_Seconds;\n```\n\nThere are a variety of opaque LabSound C objects that the labsound-c\ninterfaces will consume.\n\n```c\nstruct ls_Pin, ls_Node, ls_Connection, ls_BusData;\n```\n\nThere are a few enumerations ~\n\n```c\ntypedef enum {\n    ls_PinInvalid = 0, \n    ls_PinInput, ls_PinOutput, ls_PinParam, ls_PinSetting\n} ls_PinKind;\n\ntypedef enum {\n    ls_Invalid = 0, \n    ls_String, ls_Path, ls_Bool, ls_Int, ls_Float, ls_Bus, ls_Enum\n} ls_PinDataType;\n```\n\nThere are also some housekeeping routines. You'll need to create and release \nthe ls_API interface object, and once per frame (eg. once a game frame at\n1/60s) call `ls_idle` to give the engine a chance to do various tasks.\n\n```c\n\ntypedef struct {\n    void* (*malloc)(size_t);\n    void (*free)(void*);\n} ls_Alloc;\nconst ls_Alloc ls_default_alloc = { malloc, free };\n\nstruct ls_API* ls_create_api_1_0(ls_Alloc);\nvoid ls_release_api_1_0(struct ls_API*);\nvoid ls_idle(struct ls_API*);\n```\n\nThe LabSound C interface differs greatly from the C++ interface. The C++ \ninterface is an object oriented API meant to mimic the WebAudio specification's \ninterfaces as closely as possible. The C interfaces however, are opaque, and \nnot object oriented.\n\nNodes are created by name, and managed generically.\n\nInputs and outputs from a node are accessed from pins, as are the node's properties.\n\nThese are all built around generic interfaces that rely on LabSound's additional \nC++ interfaces for querying capabilities and attributes.\n\nPlease refer to the demo for usage examples.\n\n```c\n    // scheduling nodes\n    ls_Seconds (*node_get_timing)(struct ls_API*, ls_Node);\n    ls_Seconds (*node_get_self_timing)(struct ls_API*, ls_Node);\n    void (*node_start)(struct ls_API*, ls_Node, ls_Seconds);\n    void (*node_schedule)(struct ls_API*, ls_Node, ls_Seconds, int32_t);\n    void (*node_stop)(struct ls_API*, ls_Node, ls_Seconds);\n\n    // managing nodes\n    const ls_NameArray* (*node_names)(struct ls_API*);\n    ls_Node (*node_create)(struct ls_API*, ls_StringSlice name, ls_StringSlice type);\n    void (*node_delete)(struct ls_API*, ls_Node);\n    void (*create_node_output)(struct ls_API*, ls_Node, ls_StringSlice name, int channels);\n    void (*node_set_on_ended)(struct ls_API*, ls_Node, void(*)());\n\n    // getting pins from nodes\n    ls_Pin (*node_named_input)(struct ls_API*, ls_Node, ls_StringSlice);\n    ls_Pin (*node_indexed_input)(struct ls_API*, ls_Node, int);\n    ls_Pin (*node_named_output)(struct ls_API*, ls_Node, ls_StringSlice);\n    ls_Pin (*node_indexed_output)(struct ls_API*, ls_Node, int);\n    ls_Pin (*node_parameter)(struct ls_API*, ls_Node, ls_StringSlice);\n    ls_Pin (*node_setting)(struct ls_API*, ls_Node, ls_StringSlice);\n\n    // information about pins\n    ls_PinKind (*pin_kind)(struct ls_API*, ls_Pin);\n    ls_PinDataType (*pin_data_type)(struct ls_API*, ls_Pin);\n\n    // setting and getting pin values\n    // note - these interfaces are going to be prefixed with pin_\n    void (*set_float)(struct ls_API*, ls_Pin, float);\n    void (*set_enum)(struct ls_API*, ls_Pin, uint32_t);\n    void (*set_int)(struct ls_API*, ls_Pin, uint32_t);\n    void (*set_bool)(struct ls_API*, ls_Pin, bool);\n    void (*set_bus)(struct ls_API*, ls_Pin, ls_BusData);\n    void (*set_bus_from_file)(struct ls_API*, ls_Pin, ls_StringSlice path);\n    void (*set_named_enum)(struct ls_API*, ls_Pin, ls_StringSlice enum_name);\n\n    // managing busses\n    ls_BusData (*bus_create_from_file)(struct ls_API*, const char* path, bool mix_to_mono);\n\n    // graph management\n    // note - device_node is going to be renamed destination_node\n    ls_Node(*device_node)(struct ls_API*);\n    ls_Connection (*connect_output_to_input)(struct ls_API*, ls_Pin input, ls_Pin output);\n\n    // after disconnection, ls_Connection will no longer be valid\n    void (*disconnect)(struct ls_API*, ls_Connection);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabsound%2Flabsound-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabsound%2Flabsound-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabsound%2Flabsound-c/lists"}