{"id":13578551,"url":"https://github.com/stetre/moonsndfile","last_synced_at":"2026-02-11T08:54:22.597Z","repository":{"id":90017991,"uuid":"99554399","full_name":"stetre/moonsndfile","owner":"stetre","description":"Lua bindings for libsndfile","archived":false,"fork":false,"pushed_at":"2022-02-06T12:21:19.000Z","size":1160,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-05T16:46:19.904Z","etag":null,"topics":["audio","libsndfile","lua","lua-bindings"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stetre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-07T08:20:41.000Z","updated_at":"2024-10-06T09:57:24.000Z","dependencies_parsed_at":"2023-04-10T08:49:31.688Z","dependency_job_id":null,"html_url":"https://github.com/stetre/moonsndfile","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmoonsndfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmoonsndfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmoonsndfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stetre%2Fmoonsndfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stetre","download_url":"https://codeload.github.com/stetre/moonsndfile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393060,"owners_count":20931804,"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":["audio","libsndfile","lua","lua-bindings"],"created_at":"2024-08-01T15:01:31.740Z","updated_at":"2026-02-11T08:54:22.526Z","avatar_url":"https://github.com/stetre.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"## MoonSndFile: Lua bindings for libsndfile\n\nMoonSndFile is a Lua binding library for Erik de Castro Lopo's [libsndfile](http://www.mega-nerd.com/libsndfile/).\n\nIt runs on GNU/Linux and on Windows (MSYS2/MinGW) and requires\n[Lua](http://www.lua.org/) (\u003e=5.3) and [libsndfile](http://www.mega-nerd.com/libsndfile/#Download) (\u003e= 1.0.25).\n\n\n_Author:_ _[Stefano Trettel](https://www.linkedin.com/in/stetre)_\n\n[![Lua logo](./doc/powered-by-lua.gif)](http://www.lua.org/)\n\n#### License\n\nMIT/X11 license (same as Lua). See [LICENSE](./LICENSE).\n\n#### Documentation\n\nSee the [Reference Manual](https://stetre.github.io/moonsndfile/doc/index.html).\n\n#### Getting and installing\n\nSetup the build environment as described [here](https://github.com/stetre/moonlibs), then:\n\n```sh\n$ git clone https://github.com/stetre/moonsndfile\n$ cd moonsndfile\nmoonsndfile$ make\nmoonsndfile$ sudo make install\n```\n\nNote: that MoonSndFile does not link directly to the libsndfile library (`libsndfile.so` on Linux), \nbut it builds dynamically its own internal dispatch tables instead.\nAs a consequence, `libsndfile.so` is not needed at compile time but it is required \nat runtime, so you have to make sure that it is reachable by the linker. \nYou can do this by installing it in the standard search directories (e.g. `/usr/lib/`),\nor by properly setting the LD_LIBRARY_PATH environment variable in the shell where you execute\nthe Lua scripts. \n\n#### Example\n\nThe example below is the Lua version of the _sfprocess.c_ example that comes with libsndfile-1.0.28.\n\nOther examples can be found in the **examples/** directory contained in the release package.\n\n```lua\n-- MoonSndFile example: hello.lua\nsf = require('moonsndfile')\n\nNFRAMES = 64 -- no. of frames requested at each read\nCHANNEL_GAIN = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 }\nMAX_CHANNELS = #CHANNEL_GAIN\n\nfunction process_data(data, channels)\n   -- Unpack the data binary string to a table of doubles:\n   local data = sf.unpack('double', data)\n\n   -- Process the data (apply a channel dependent gain):\n   for chan = 1, channels do\n      for k = chan, #data, channels do\n         data[k] = data[k] * CHANNEL_GAIN[chan]\n      end\n   end\n   \n   -- Pack the table of doubles to a binary string, and return it:\n   return sf.pack('double', data)\nend\n\n-- Open the input file:\ninfile, fileinfo = sf.open(\"input.wav\", 'r')\n\nif fileinfo.channels \u003e MAX_CHANNELS then\n   error(\"Not able to process more than \"..MAX_CHANNELS.. \"channels\")\nend\n\n-- Open the output file, with the same properties as the input file:\noutfile, fileinfo = sf.open(\"output.wav\", 'w', fileinfo)\n\n-- Read input frames / process them / write output frames:\nwhile true do \n   local data, nframes = sf.read(infile, 'double', NFRAMES)\n   if not data then break end\n   data = process_data(data, fileinfo.channels)\n   sf.write(outfile, 'double', data)\nend\n\n-- Close files:\nsf.close(infile)\nsf.close(outfile)\n```\n\nThe script can be executed at the shell prompt with the standard Lua interpreter:\n\n```shell\n$ lua hello.lua\n```\n\n#### See also\n\n* [MoonLibs - Graphics and Audio Lua Libraries](https://github.com/stetre/moonlibs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstetre%2Fmoonsndfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstetre%2Fmoonsndfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstetre%2Fmoonsndfile/lists"}