{"action":"created","issue":{"url":"https://api.github.com/repos/soumith/lua---audio/issues/11","repository_url":"https://api.github.com/repos/soumith/lua---audio","labels_url":"https://api.github.com/repos/soumith/lua---audio/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/soumith/lua---audio/issues/11/comments","events_url":"https://api.github.com/repos/soumith/lua---audio/issues/11/events","html_url":"https://github.com/soumith/lua---audio/issues/11","id":135271027,"number":11,"title":"audio.decompress from lua i/o?","user":{"login":"willfrey","id":13784361,"avatar_url":"https://avatars.githubusercontent.com/u/13784361?v=3","gravatar_id":"","url":"https://api.github.com/users/willfrey","html_url":"https://github.com/willfrey","followers_url":"https://api.github.com/users/willfrey/followers","following_url":"https://api.github.com/users/willfrey/following{/other_user}","gists_url":"https://api.github.com/users/willfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/willfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willfrey/subscriptions","organizations_url":"https://api.github.com/users/willfrey/orgs","repos_url":"https://api.github.com/users/willfrey/repos","events_url":"https://api.github.com/users/willfrey/events{/privacy}","received_events_url":"https://api.github.com/users/willfrey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-21T22:46:31Z","updated_at":"2016-02-22T16:38:23Z","closed_at":"2016-02-22T16:38:23Z","body":"Is there any way to do the following?\r\n\r\n```lua\r\nrequire 'audio'\r\n\r\nfile = io.open(\"foo.wav\", \"r\")\r\n-- reading all to get the RIFF header\r\n-- could offset to get the raw audio if sample rate is known\r\ncontents = file:read(\"*all\")\r\nfile:close()\r\n    \r\nchars = torch.CharTensor(#contents)\r\nchars:storage():string(contents)\r\n\r\nsignal = audio.decompress(chars, 'wav')\r\n```\r\n\r\nI tried playing around with it a little but but your audio.compress seems to compress the file down to a larger size CharTensor than I expected. For example, suppose that foo.wav is 1 second long with a sample rate of 16kHz — so, 16000 samples. Each sample is a short, so I expect to have 2 * 16000 = 32000 bytes or chars when I compress it to a CharTensor. However, audio.compress will compress it to a 3 * 16000 = 48000 length CharTensor.\r\n\r\nI assume this has something to do with embedding the sample rate.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/soumith/lua---audio/issues/comments/187257161","html_url":"https://github.com/soumith/lua---audio/issues/11#issuecomment-187257161","issue_url":"https://api.github.com/repos/soumith/lua---audio/issues/11","id":187257161,"user":{"login":"willfrey","id":13784361,"avatar_url":"https://avatars.githubusercontent.com/u/13784361?v=3","gravatar_id":"","url":"https://api.github.com/users/willfrey","html_url":"https://github.com/willfrey","followers_url":"https://api.github.com/users/willfrey/followers","following_url":"https://api.github.com/users/willfrey/following{/other_user}","gists_url":"https://api.github.com/users/willfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/willfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willfrey/subscriptions","organizations_url":"https://api.github.com/users/willfrey/orgs","repos_url":"https://api.github.com/users/willfrey/repos","events_url":"https://api.github.com/users/willfrey/events{/privacy}","received_events_url":"https://api.github.com/users/willfrey/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T16:38:23Z","updated_at":"2016-02-22T16:38:23Z","body":"Closing this. It was easy enough to convert two bytes into a short."}}