]> Sergey Matveev's repositories - go-opus.git/commitdiff
README: camelCase
authorHraban Luyat <hraban@0brg.net>
Fri, 6 Jan 2017 22:10:15 +0000 (22:10 +0000)
committerHraban Luyat <hraban@0brg.net>
Fri, 6 Jan 2017 22:10:15 +0000 (22:10 +0000)
README.md

index 9405d3d25407f829cf20e8ade0b15c42a917575b..b383a9ba0bce23b3993fa82705db7693c973feed 100644 (file)
--- a/README.md
+++ b/README.md
@@ -22,10 +22,10 @@ xiph.org opus libs:
 To encode raw audio to the Opus format, create an encoder first:
 
 ```go
-const sample_rate = 48000
+const sampleRate = 48000
 const channels = 1 // mono; 2 for stereo
 
-enc, err := opus.NewEncoder(sample_rate, channels, opus.APPLICATION_VOIP)
+enc, err := opus.NewEncoder(sampleRate, channels, opus.AppVoIP)
 if err != nil {
     ...
 }
@@ -40,19 +40,19 @@ documentation](https://www.opus-codec.org/docs/opus_api-1.1.3/group__opus__encod
 
 ```go
 var pcm []int16 = ... // obtain your raw PCM data somewhere
-const buffer_size = 1000 // choose any buffer size you like. 1k is plenty.
+const bufferSize = 1000 // choose any buffer size you like. 1k is plenty.
 
 // Check the frame size. You don't need to do this if you trust your input.
-frame_size := len(pcm) // must be interleaved if stereo
-frame_size_ms := float32(frame_size) / channels * 1000 / sample_rate
-switch frame_size_ms {
+frameSize := len(pcm) // must be interleaved if stereo
+frameSizeMs := float32(frameSize) / channels * 1000 / sampleRate
+switch frameSizeMs {
 case 2.5, 5, 10, 20, 40, 60:
     // Good.
 default:
-    return fmt.Errorf("Illegal frame size: %d bytes (%f ms)", frame_size, frame_size_ms)
+    return fmt.Errorf("Illegal frame size: %d bytes (%f ms)", frameSize, frameSizeMs)
 }
 
-data := make([]byte, buffer_size)
+data := make([]byte, bufferSize)
 n, err := enc.Encode(pcm, data)
 if err != nil {
     ...
@@ -74,7 +74,7 @@ the encoding process:
 To decode opus data to raw PCM format, first create a decoder:
 
 ```go
-dec, err := opus.NewDecoder(sample_rate, channels)
+dec, err := opus.NewDecoder(sampleRate, channels)
 if err != nil {
     ...
 }
@@ -83,9 +83,9 @@ if err != nil {
 Now pass it the opus bytes, and a buffer to store the PCM sound in:
 
 ```go
-var frame_size_ms float32 = ...  // if you don't know, go with 60 ms.
-frame_size := channels * frame_size_ms * sample_rate / 1000
-pcm := make([]byte, int(frame_size))
+var frameSizeMs float32 = ...  // if you don't know, go with 60 ms.
+frameSize := channels * frameSizeMs * sampleRate / 1000
+pcm := make([]byte, int(frameSize))
 n, err := dec.Decode(data, pcm)
 if err != nil {
     ...