fix dumping of raw PCM audio
This commit is contained in:
parent
8fa584775f
commit
3df1d842f3
|
@ -13,12 +13,9 @@ import (
|
|||
|
||||
"layeh.com/gumble/gumble"
|
||||
"layeh.com/gumble/gumbleutil"
|
||||
_ "layeh.com/gumble/opus" // it's a good idea to load this: botamusique crashes because of a CodecNotSupportedError EXception
|
||||
_ "layeh.com/gumble/opus"
|
||||
)
|
||||
|
||||
func audiolistener(e *gumble.AudioStreamEvent) {
|
||||
}
|
||||
|
||||
type AudioListener struct {
|
||||
name string
|
||||
}
|
||||
|
@ -28,33 +25,16 @@ func (audiolistener AudioListener) OnAudioStream(e *gumble.AudioStreamEvent) {
|
|||
go ReadPacket(e.C)
|
||||
}
|
||||
|
||||
// func PcmToMp3(pcmFileName, mp3FileName string) {
|
||||
// pcmFile, _ := os.OpenFile(pcmFileName, os.O_RDONLY, 0555)
|
||||
// mp3File, _ := os.OpenFile(mp3FileName, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
|
||||
// defer mp3File.Close()
|
||||
// wr, err := lame.NewWriter(mp3File)
|
||||
// if err != nil {
|
||||
// panic("cannot create lame writer, err: " + err.Error())
|
||||
|
||||
// }
|
||||
// io.Copy(wr, pcmFile)
|
||||
// wr.Close()
|
||||
|
||||
// }
|
||||
|
||||
type AudioEncoder struct {
|
||||
}
|
||||
|
||||
func ReadPacket(ch <-chan *gumble.AudioPacket) { // receive-only channel
|
||||
pcm_out, _ := os.OpenFile("pcm_out.raw", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
|
||||
func ReadPacket(ch <-chan *gumble.AudioPacket) {
|
||||
outFile := "pcm_out.raw"
|
||||
fmt.Printf("Saving out to %s", outFile) // debug
|
||||
pcm_out, _ := os.OpenFile(outFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
|
||||
defer pcm_out.Close()
|
||||
//func (f *File) Write(b []byte) (n int, err error)
|
||||
|
||||
for packet := range ch {
|
||||
fmt.Println(packet.Sender.Name)
|
||||
// fmt.Printf("%:+v\n", packet)
|
||||
// pkt := <-ch
|
||||
// buf := pkt.AudioBuffer
|
||||
// pcm_out.Write(UnsafeCastInt16sToBytes(buf))
|
||||
// log.Printf("Message from %s", packet.Sender.Name) // debug
|
||||
buf := packet.AudioBuffer
|
||||
pcm_out.Write(UnsafeCastInt16sToBytes(buf))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +63,7 @@ func main() {
|
|||
|
||||
}
|
||||
|
||||
// Print available channels on the server
|
||||
fmt.Printf("Channels:\n")
|
||||
for idx, channel := range client.Channels {
|
||||
fmt.Printf("\t%d - %s\n", idx, channel.Name)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package main
|
||||
|
||||
import "unsafe"
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const BYTES_IN_INT32 = 4
|
||||
const BYTES_IN_INT16 = 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user