{"action":"opened","issue":{"url":"https://api.github.com/repos/azul3d/audio/issues/14","labels_url":"https://api.github.com/repos/azul3d/audio/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/azul3d/audio/issues/14/comments","events_url":"https://api.github.com/repos/azul3d/audio/issues/14/events","html_url":"https://github.com/azul3d/audio/issues/14","id":124559745,"number":14,"title":"How do you get volume levels from samples?","user":{"login":"Xeoncross","id":56460,"avatar_url":"https://avatars.githubusercontent.com/u/56460?v=3","gravatar_id":"","url":"https://api.github.com/users/Xeoncross","html_url":"https://github.com/Xeoncross","followers_url":"https://api.github.com/users/Xeoncross/followers","following_url":"https://api.github.com/users/Xeoncross/following{/other_user}","gists_url":"https://api.github.com/users/Xeoncross/gists{/gist_id}","starred_url":"https://api.github.com/users/Xeoncross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xeoncross/subscriptions","organizations_url":"https://api.github.com/users/Xeoncross/orgs","repos_url":"https://api.github.com/users/Xeoncross/repos","events_url":"https://api.github.com/users/Xeoncross/events{/privacy}","received_events_url":"https://api.github.com/users/Xeoncross/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-01T20:11:47Z","updated_at":"2016-01-01T20:11:47Z","closed_at":null,"body":"I'm trying to get the volume level each X ms so I can monitor the volume of the input stream or a file fed to the program.\r\n\r\n\r\n    cat example.wav | go run volume.go\r\n\r\nThe samples are all float64 so I'm not sure what data is contained in the number or what to do with it in order to find the volume level.\r\n\r\n\t// Open audio decoder on input stream\r\n\tdecoder, _, err := audio.NewDecoder(os.Stdin)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\t// samples is a slice of float64 audio samples, used to store decoded values\r\n\tconfig := decoder.Config()\r\n\tsamples := make(audio.F64Samples, uint(config.SampleRate*config.Channels))\r\n\tfor {\r\n\t\t// Decode at specified resolution from options\r\n\t\t// On any error other than end-of-stream, return\r\n\t\t_, err := decoder.Read(samples)\r\n\t\tif err != nil && err != audio.EOS {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\r\n\t\tfmt.Println(\"samples\", samples)\r\n\r\n\t\t// On end of stream, stop reading values\r\n\t\tif err == audio.EOS {\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n\r\nHow do you watch the volume level every X samples or X ms?"}}