go_ph0n3

package module
v0.0.0-...-36fd63a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-ph0n3

Virtual DTMF phone dialing simulator / tones generator it is uses Oto lib (by Hajime Hoshi) as sound lib and is based on Oto's example which is licensed under the Apache License Version 2.0.

Example:

package main

import go_ph0n3 "github.com/umarquez/go-ph0n3"

func main() {
	phone := go_ph0n3.NewPh0n3(nil).Open()
	_ = phone.DialString("13243546")
	<-phone.Close
}

Documentation

Overview

go_ph0n3 is a virtual DTMF phone dialing simulator / tones generator it is uses Oto as sound lib and is based on Oto's example wich is licensed under the Apache License Version 2.0. https://github.com/hajimehoshi/oto/blob/master/example/main.go

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultPh0n3Options = &Ph0n3Options{
	SpaceDuration:    time.Second / 15,
	DialToneDuration: 2,
	ToneDuration:     time.Second / 4,
	BuffSizeBytes:    4096,
	Channel:          1,
	RingingToneTimes: 2,
	BusyToneTimes:    4,
	Vervose:          false,
}

DefaultPh0n3Options the default values.

View Source
var StandarPad = map[string]Ph0n3Key{
	"1": Key1,
	"2": Key2,
	"A": Key2,
	"B": Key2,
	"C": Key2,
	"3": Key3,
	"D": Key3,
	"E": Key3,
	"F": Key3,
	"4": Key4,
	"G": Key4,
	"H": Key4,
	"I": Key4,
	"5": Key5,
	"J": Key5,
	"K": Key5,
	"L": Key5,
	"6": Key6,
	"M": Key6,
	"N": Key6,
	"O": Key6,
	"7": Key7,
	"P": Key7,
	"R": Key7,
	"S": Key7,
	"8": Key8,
	"T": Key8,
	"U": Key8,
	"V": Key8,
	"9": Key9,
	"W": Key9,
	"X": Key9,
	"Y": Key9,
	"0": Key0,
	"*": KeyStar,
	"#": KeyHash,
}

StandarPad is a map of the standard phone keys and its values to the DTMF key that it belongs. This allows you to dial numbers like: 01-800-SOMETHING.

Functions

This section is empty.

Types

type Ph0n3

type Ph0n3 struct {
	Close chan bool
	// contains filtered or unexported fields
}

Ph0n3 is a phone toy you can use to dial a number; it also could be used as dialing tone generator.

Example
phone := go_ph0n3.NewPh0n3(nil).Open()
_ = phone.DialString("13243546")
<-phone.Close

func NewPh0n3

func NewPh0n3(opt *Ph0n3Options) *Ph0n3

NewPh0n3 returns a new phone instance ready to use

func (*Ph0n3) Dial

func (phone *Ph0n3) Dial(keys ...Ph0n3Key) error

Dial dials a key sequence

func (*Ph0n3) DialString

func (phone *Ph0n3) DialString(text string) error

DialString dial keys from the given strings, if a char does not exists it skips and continue with next.

func (*Ph0n3) Open

func (phone *Ph0n3) Open() *Ph0n3

Open opens the line with a dial tone

type Ph0n3Key

type Ph0n3Key int

Ph0n3Key are keys of the DMTF System

const (
	Key1 Ph0n3Key = iota
	Key2
	Key3
	KeyA
	Key4
	Key5
	Key6
	KeyB
	Key7
	Key8
	Key9
	KeyC
	KeyStar
	Key0
	KeyHash
	KeyD
)

This constants will gonna be safe indexes, we are just ensuring that only defined value will be used; tit is based on the standard 16 key names of the DTMF (Dual-Tone Multi-Frequency) System. https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling

type Ph0n3Options

type Ph0n3Options struct {
	// SpaceDuration Time between tones
	SpaceDuration time.Duration `json:"space_duration"`
	// ToneDuration Time a tone sounds
	ToneDuration time.Duration `json:"tone_duration"`
	// DialToneDuration Time during the dial tone will sound before dial 0 = disabled.
	DialToneDuration time.Duration `json:"dial_tone_duration"`
	// RingingToneTimes Times the ringing tone will sounds after dialing,
	// 0 for disable.
	RingingToneTimes int
	// BusyTonesTimes Times the busy tone will sounds before the call ends,
	// 0 for disable.
	BusyToneTimes int
	// Channel The sound channel number to be used to play the tones.
	Channel int
	// BuffSizeBytes is the buffer size in bytes
	BuffSizeBytes int
	// Vervose enables debug messages (the number that is been dialed)
	Vervose bool
}

Ph0n3Options Defines the behavior of a Ph0n3 instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址