A simple application that just plays a pure tone
This repository has been archived on 2021-12-22. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Go 95.6%
  • Makefile 4.4%
Find a file
2021-12-22 14:53:32 +01:00
.gitignore Initial commit 2021-12-11 18:34:45 +01:00
go.mod Update import paths 2021-12-11 18:48:49 +01:00
go.sum go mod tidy 2021-12-12 13:25:37 +01:00
LICENSE Initial commit 2021-12-11 18:34:45 +01:00
main.go Update desc 2021-12-22 14:53:32 +01:00
Makefile Initial commit 2021-12-11 18:34:45 +01:00
README.md Update desc 2021-12-22 11:02:04 +01:00
wave.go Rename func 2021-12-12 13:21:16 +01:00

gone

A simple application that just plays a pure tone

This application is based on the example of the oto library, which is used by this application.

Usage

Play a frequency:

gone [options] [frequencies] [duration]

The frequencies are played for the duration and if one frequency finishes, the next starts (the duration must be the last argument).

Options

Option Usage
-samplerate sample rate
-channel number of channel
-bitdepth bit depth in bytes

View help:

gone help

Build

Requires Go for compilation, gofumpt for code formatting and golangci-lint to run linters.

To build the code

make

or

make build

or if you don't have make installed

go build

To reformat the code:

make fmt

To run linters (will automatically format your code with gofumpt)

make lint

or if you don't want to format your code (linter may fail)

make lint-only

Use as library

You can use gone as a library to play frequencies. Therefore, install it with go get codeberg.org/qwerty287/gone.

Example

package main

import (
	"time"

	"codeberg.org/qwerty287/gone"
)

func main() {
	context, err := gone.NewContext() // returns a gone.Context with default values
	if err != nil {
		return
	}

	// if you need other values as sample rate, channel and bit depth use
	// gone.NewContextWithParameters(sample rate, channel, bit depth)

	frequency := 500.0
	// works best with times under 9 seconds
	duration := 6 * time.Second

	// PlayFrequency waits until sound is finished
	context.PlayFrequency(frequency, duration)

	// PlayFrequencyAndContinue continues after start playing the tone
	context.PlayFrequencyAndContinue(frequency, duration)

	// if you need the oto.Context directly
	context.OtoContext.Suspend()
}