{"id":17961345,"url":"https://github.com/xavriley/fast_osc","last_synced_at":"2025-06-22T02:35:15.174Z","repository":{"id":56846033,"uuid":"54587697","full_name":"xavriley/fast_osc","owner":"xavriley","description":"A Ruby wrapper around rtosc (https://github.com/fundamental/rtosc/) to encode and decode OSC messages.","archived":false,"fork":false,"pushed_at":"2020-03-17T16:05:15.000Z","size":119,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-29T07:58:07.715Z","etag":null,"topics":["ruby"],"latest_commit_sha":null,"homepage":"","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/xavriley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-23T19:34:01.000Z","updated_at":"2023-07-25T14:01:00.000Z","dependencies_parsed_at":"2022-09-17T21:53:29.285Z","dependency_job_id":null,"html_url":"https://github.com/xavriley/fast_osc","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/xavriley/fast_osc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavriley%2Ffast_osc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavriley%2Ffast_osc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavriley%2Ffast_osc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavriley%2Ffast_osc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xavriley","download_url":"https://codeload.github.com/xavriley/fast_osc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xavriley%2Ffast_osc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261225558,"owners_count":23127167,"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":["ruby"],"created_at":"2024-10-29T11:09:06.681Z","updated_at":"2025-06-22T02:35:10.156Z","avatar_url":"https://github.com/xavriley.png","language":"C","readme":"# FastOsc\n\nA Ruby wrapper around [rtosc](https://github.com/fundamental/rtosc/) to encode and decode OSC messages.\n\nThis also includes a fallback implementation in pure Ruby in the case that the compiled version doesn't load properly. This can be forced by setting an environment variable of `FAST_OSC_USE_FALLBACK=1` where needed.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'fast_osc'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install fast_osc\n\n## Usage\n\nEverything (single messages and bundles) can be parsed with a single method -\n`FastOsc.decode`. This outputs an array of bundles, with each bundle containing\na timestamp and an array of messages. Each message contains a path and,\noptionally, some arguments.\n\n```ruby\n# encode an OSC message with the established Ruby OSC libary\n@msg = OSC::Message.new(\"/testpath\", [\"some\", \"args\", 1, 2.0]).encode\n@encoded_msg = @msg1.encode\n\nFastOsc.decode(@encoded_msg0).each do |bundle|\n  _timestamp, osc_msgs = bundle\n\n  osc_msgs.each do |(path, args)|\n    puts @path # \"/testpath\"\n    puts args # [\"some\", \"args\", 1, 2.0]\n  end\nend\n```\n\n```\n\u003e\u003e FastOsc.encode_single_message(\"/foo\", [\"baz\", 1, 2.0])\n=\u003e \"/foo\\x00\\x00\\x00\\x00,sif\\x00\\x00\\x00\\x00baz\\x00\\x00\\x00\\x00\\x01@\\x00\\x00\\x00\"\n\u003e\u003e res = _\n\u003e\u003e FastOsc.decode_no_bundles(res)\n=\u003e [\"/foo\", [\"baz\", 1, 2.0]]\n\u003e\u003e FastOsc.encode_single_bundle(Time.now.to_i, \"/foo\", [\"baz\", 1, 2.0])\n=\u003e \"#bundle\\x00\\x00\\x00\\x00\\x00W*1\\x7F\\x00\\x00\\x00\\x1C/foo\\x00\\x00\\x00\\x00,sif\\x00\\x00\\x00\\x00baz\\x00\\x00\\x00\\x00\\x01@\\x00\\x00\\x00\"\n```\n\n A timestamp of `nil` is a special case meaning \"immediately\".\n\n### A note on types\n\nTo represent the `blob` type tag from the OSC spec, FastOsc uses strings with\nthe `ASCII-8BIT` encoding. UTF-8 strings remain as normal string tags.\n\nFor examples of this, see the test suite.\n\n## Is it fast?\n\nLet's see...\n\nKey:\n\n* `fast_osc` - this gem\n* `osc` - [`osc-ruby`](https://github.com/aberant/osc-ruby)\n* `samsosc` - `OSC` classes from Sonic Pi (which are optimised pure Ruby based on `pack` and `unpack`)\n\n### Encoding Benchmark\n\n```\n$ WITH_BENCHMARKS=1 rake test\nWarming up --------------------------------------\n            fast_osc    94.043k i/100ms\n             samsosc    41.231k i/100ms\n            osc-ruby    17.476k i/100ms\nCalculating -------------------------------------\n            fast_osc      1.186M (± 3.7%) i/s -      5.925M in   5.004014s\n             samsosc    458.561k (± 4.1%) i/s -      2.309M in   5.043860s\n            osc-ruby    182.051k (± 4.6%) i/s -    908.752k in   5.003313s\nDECODING TEST\n```\n\n### Decoding Bencmark\n\n```\n$ WITH_BENCHMARKS=1 rake test\nWarming up --------------------------------------\n            fast_osc   208.209k i/100ms\n             samsosc    38.760k i/100ms\n            osc-ruby     6.844k i/100ms\nCalculating -------------------------------------\n            fast_osc      3.679M (± 3.8%) i/s -     18.531M in   5.044888s\n             samsosc    430.488k (± 3.0%) i/s -      2.171M in   5.046837s\n            osc-ruby     70.998k (± 3.1%) i/s -    355.888k in   5.017493s\n```\n\nBenchmarks are now part of this repo - run `WITH_BENCHMARKS=1 rake test` to see the results for yourself.\n\n## Still todo\n\n- [x] Make a pure ruby fallback available\n- [x] Implement more types\n- [x] Bring benchmarks into the repo\n- [ ] Work out cross compilation story for easier packaging\n- [x] Implement multi message/nested bundles\n- [ ] More documentation\n- [x] Travis, Appveyor\n\n## Development notes\n\nThis project uses Bundler v2 - get this with\n\n    gem install bundler\n\nOn linux, the only deps are `apt-get install build-essentials ruby-devel`. On OS X you may need XCode build tooling or similar.\n\n    bundle install\n    rake compile\n\nOn Windows, using RubyInstaller and setup the MSYS2 toolchain. You then need to include devkit in the compile step like so:\n\n    bundle install\n    bundle exec rake compile -rdevkit\n\n### Running the test suite\n\n```\n$ gem install minitest # or bundle install\n$ rake clean \u0026\u0026 rake clobber \u0026\u0026 rake compile \u0026\u0026 rake test \u0026\u0026 FAST_OSC_USE_FALLBACK=true rake test\n```\n\nhttps://gist.github.com/xavriley/507eff0a75d4552fa56e\n\n## Contributing\n\n1. Fork it ( http://github.com/\u003cmy-github-username\u003e/fast_osc/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavriley%2Ffast_osc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxavriley%2Ffast_osc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxavriley%2Ffast_osc/lists"}