Skip to content

davidae/audiostream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

audiostream

GoDoc

audiostream is a simple streaming API for audio files. It can easily be used together with a HTTP server to stream audio to a HTTP client.

This is package is used in an ongoing effort together with another private project.

What does the API do?

  • It implements the ICY protocol. It's optional to use.
  • It will read files (io.Reader) (assumed audio/media but technically not required) from an append-able queue.
  • It will broadcast the files to any listeners in frames of bytes and the listeners can read it as a stream via channels.

What does the API not do?

  • It does not implement the SHOUTcast or Icecast protocol.
  • It cannot decode, convert or manipulate audio files. Its up to the implementor to deal with this. A decoder package can solve this and ffmpeg can deal with converting sample rates if needed.

Example

See how to use the audiostream together with an HTTP server in examples/main.go

A small example here,

package main

import (
	"fmt"
	"strings"

	"github.com/davidae/audiostream"
)

func main() {
	stream := audiostream.NewStream(audiostream.WithFramzeSize(2))

	stream.AppendAudio(&audiostream.Audio{
		Data:       strings.NewReader("thisIsForSureNotAProperAudioFileThough"),
		Artist:     "Fizz",
		Title:      "Buzz",
		SampleRate: 44100,
	})

	listener, err := audiostream.NewListener()
	if err != nil {
		panic(err)
	}
	stream.AddListener(listener)

	go func() {
		for {
			fmt.Printf("listener: %s\n", <-listener.Stream())
		}
	}()
	stream.Start()
}

Inspiration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages