当前位置: 首页>>代码示例>>Golang>>正文


Golang portaudio.Terminate函数代码示例

本文整理汇总了Golang中github.com/gordonklaus/portaudio.Terminate函数的典型用法代码示例。如果您正苦于以下问题:Golang Terminate函数的具体用法?Golang Terminate怎么用?Golang Terminate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Terminate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	var m Meter
	m.Initialize()
	defer portaudio.Terminate()

	var FLAGS_list = false
	flag.BoolVar(&FLAGS_list, "l", false, "List all devices")

	flag.Parse()

	if FLAGS_list {
		m.LogDevices()
		return
	}

	s := m.OpenStream()
	defer s.Close()
	select {
	// Wait forever.
	}
	if err := s.Stop(); err != nil {
		fmt.Printf("portaudio.Stream.Stop failed: ", err)
		return
	}
}
开发者ID:davidhubbard,项目名称:gosphinx,代码行数:25,代码来源:2filter.go

示例2: finishInitialisation

func (spotify *Spotify) finishInitialisation(webApiAuth bool, pa *portAudio) error {
	if webApiAuth {
		if spotify.client = webapi.Auth(); spotify.client != nil {
			if privateUser, err := spotify.client.CurrentUser(); err == nil {
				if privateUser.ID != spotify.session.LoginUsername() {
					return errors.New("Username doesn't match with web-api authorization")
				}
			} else {
				spotify.client = nil
			}
		}
	}
	// init audio could happen after initPlaylist but this logs to output therefore
	// the screen isn't built properly
	portaudio.Initialize()
	go pa.player()
	defer portaudio.Terminate()

	if err := spotify.initPlaylist(); err != nil {
		return err
	}

	spotify.waitForEvents()
	return nil
}
开发者ID:rdbrdd,项目名称:sconsify,代码行数:25,代码来源:spotify.go

示例3: main

func main() {
	flag.Parse()

	portaudio.Initialize()
	defer portaudio.Terminate()

	portmidi.Initialize()
	defer portmidi.Terminate()

	if *doDemo {
		if err := demo(); err != nil {
			log.Println(err)
		}
		return
	}

	http.Handle("/", http.FileServer(http.Dir("static")))
	http.HandleFunc("/socket", socket.Handler)

	l, err := net.Listen("tcp", *listenAddr)
	if err != nil {
		log.Fatal(err)
	}
	go http.Serve(l, nil)

	u := fmt.Sprintf("http://%v/", *listenAddr)
	if !*doBrowser || !openBrowser(u) {
		fmt.Printf("Open your web browser to %v\n\n", u)
	}

	fmt.Println("Press enter to quit...")
	os.Stdin.Read([]byte{0})
}
开发者ID:lamproae,项目名称:sigourney,代码行数:33,代码来源:main.go

示例4: main

func main() {
	w := &window{voices: map[int]*sineVoice{}}
	p := audio.Params{SampleRate: 96000}
	audio.Init(w, p)

	portaudio.Initialize()
	defer portaudio.Terminate()
	s, err := portaudio.OpenDefaultStream(0, 1, p.SampleRate, 64, w.processAudio)
	if err != nil {
		fmt.Println(err)
		return
	}
	if err := s.Start(); err != nil {
		fmt.Println(err)
		return
	}
	defer s.Stop()

	if err := gui.Run(func() {
		gui.NewWindow(w, "beep", func(win *gui.Window) {
			w.Window = win
			gui.SetKeyFocus(w)
		})
	}); err != nil {
		fmt.Println(err)
	}
}
开发者ID:gordonklaus,项目名称:songs,代码行数:27,代码来源:beep.go

示例5: main

func main() {
	portaudio.Initialize()
	defer portaudio.Terminate()
	hs, err := portaudio.HostApis()
	chk(err)
	err = tmpl.Execute(os.Stdout, hs)
	chk(err)
}
开发者ID:charneykaye,项目名称:portaudio,代码行数:8,代码来源:enumerate.go

示例6: OnTerm

func (a *app) OnTerm() {
	if a.pastream != nil {
		a.pastream.Stop()
		a.pastream.Close()
		chk(portaudio.Terminate())
	}
	a.r.Close()
}
开发者ID:jacereda,项目名称:webmplay,代码行数:8,代码来源:webmplay.go

示例7: main

func main() {
	portaudio.Initialize()
	defer portaudio.Terminate()
	s := newStereoSine(256, 320, sampleRate)
	defer s.Close()
	chk(s.Start())
	time.Sleep(2 * time.Second)
	chk(s.Stop())
}
开发者ID:charneykaye,项目名称:portaudio,代码行数:9,代码来源:stereoSine.go

示例8: main

func main() {
	portaudio.Initialize()
	defer portaudio.Terminate()
	e := newEcho(time.Second / 3)
	defer e.Close()
	chk(e.Start())
	time.Sleep(4 * time.Second)
	chk(e.Stop())
}
开发者ID:charneykaye,项目名称:portaudio,代码行数:9,代码来源:echo.go

示例9: record

// Slightly modified exact copy of the portaudio example
func record(f *os.File, timer <-chan time.Time) {
	// form chunk
	_, _ = f.WriteString("FORM")
	binary.Write(f, binary.BigEndian, int32(0))
	_, _ = f.WriteString("AIFF")

	// common chunk
	_, _ = f.WriteString("COMM")
	binary.Write(f, binary.BigEndian, int32(18))
	binary.Write(f, binary.BigEndian, int16(1))
	binary.Write(f, binary.BigEndian, int32(0))
	binary.Write(f, binary.BigEndian, int16(32))
	_, _ = f.Write([]byte{0x40, 0x0e, 0xac, 0x44, 0, 0, 0, 0, 0, 0}) //80-bit sample rate 44100

	// sound chunk
	_, _ = f.WriteString("SSND")
	binary.Write(f, binary.BigEndian, int32(0))
	binary.Write(f, binary.BigEndian, int32(0))
	binary.Write(f, binary.BigEndian, int32(0))
	nSamples := 0
	defer func() {
		// fill in missing sizes
		totalBytes := 4 + 8 + 18 + 8 + 8 + 4*nSamples
		_, _ = f.Seek(4, 0)
		binary.Write(f, binary.BigEndian, int32(totalBytes))
		_, _ = f.Seek(22, 0)
		binary.Write(f, binary.BigEndian, int32(nSamples))
		_, _ = f.Seek(42, 0)
		binary.Write(f, binary.BigEndian, int32(4*nSamples+8))
		f.Close()
	}()

	portaudio.Initialize()
	defer portaudio.Terminate()
	in := make([]int32, 64)
	stream, _ := portaudio.OpenDefaultStream(1, 0, 44100, len(in), in)
	defer stream.Close()

	stream.Start()
	defer stream.Stop()

	for {
		stream.Read()
		binary.Write(f, binary.BigEndian, in)
		nSamples += len(in)
		select {
		case <-timer:
			return
		default:
		}
	}
}
开发者ID:kladd,项目名称:stt,代码行数:53,代码来源:stt.go

示例10: finishInitialisation

func (spotify *Spotify) finishInitialisation(pa *portAudio) error {
	// init audio could happen after initPlaylist but this logs to output therefore
	// the screen isn't built properly
	portaudio.Initialize()
	go pa.player()
	defer portaudio.Terminate()

	if err := spotify.initPlaylist(); err != nil {
		return err
	}

	spotify.waitForEvents()
	return nil
}
开发者ID:KoehlerClem,项目名称:sconsify,代码行数:14,代码来源:spotify.go

示例11: main

func main() {
	portaudio.Initialize()
	defer portaudio.Terminate()
	h, err := portaudio.DefaultHostApi()
	chk(err)
	stream, err := portaudio.OpenStream(portaudio.HighLatencyParameters(nil, h.DefaultOutputDevice), func(out []int32) {
		for i := range out {
			out[i] = int32(rand.Uint32())
		}
	})
	chk(err)
	defer stream.Close()
	chk(stream.Start())
	time.Sleep(time.Second)
	chk(stream.Stop())
}
开发者ID:charneykaye,项目名称:portaudio,代码行数:16,代码来源:noise.go

示例12: main

func main() {
	flag.Parse()
	if *random {
		*seed = time.Now().UnixNano()
		fmt.Println("seed =", *seed)
	}
	if *seed != math.MinInt64 {
		*random = true
	}
	rand.Seed(*seed)

	portaudio.Initialize()
	defer portaudio.Terminate()

	p := audio.Params{SampleRate: 48000}

	m := audio.MultiVoice{}
	audio.Init(&m, p)
	// for _, x := range [][2]float64{{1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {3, 2}, {4, 3}, {5, 4}, {7, 4}, {6, 5}, {7, 5}, {8, 5}, {9, 5}} {
	for xy := 1; xy <= 60; xy++ {
		for x := 2; x <= int(math.Sqrt(float64(xy))); x++ {
			if y := xy / x; x*y == xy && relPrime(x, y) {
				x, y, xy := float64(x), float64(y), float64(xy)
				c := math.Exp(-xy * math.Log2(y/x) / 12)
				f := y / x
				phase := 0.0
				if *random {
					phase = rand.Float64()
				}
				m.Add(newSineBeat(.5*c, 128*f, 1/xy, phase, .1/f))
			}
		}
	}

	s, err := portaudio.OpenDefaultStream(0, 1, p.SampleRate, 512, func(out []float32) {
		for i := range out {
			out[i] = float32(audio.Saturate(m.Sing()))
		}
	})
	if err != nil {
		panic(err)
	}
	s.Start()
	fmt.Println("Press Enter to stop.")
	fmt.Scanln()
	s.Stop()
}
开发者ID:gordonklaus,项目名称:songs,代码行数:47,代码来源:boop.go

示例13: init

func init() {
	portaudio.Initialize()
	go func() {
		defer os.Exit(0)
		sig := make(chan os.Signal, 1)
		signal.Notify(sig)
		if <-sig == syscall.SIGQUIT {
			buf := make([]byte, 1<<10)
			for runtime.Stack(buf, true) == len(buf) {
				buf = make([]byte, 2*len(buf))
			}
			fmt.Fprintln(os.Stderr, string(buf))
		}
		for _, c := range playControls {
			c.Stop()
			<-c.Done
		}
		portaudio.Terminate()
	}()
}
开发者ID:gordonklaus,项目名称:audio,代码行数:20,代码来源:play_other.go

示例14: Start

func (self *Server) Start() error {
	portaudio.Initialize()
	defer portaudio.Terminate()

	var err error

	if err = self.startAudio(); err != nil {
		return err
	}

	if err = self.startSerial(); err != nil {
		return err
	}

	if err = self.startHttp(); err != nil {
		return err
	}

	return nil
}
开发者ID:tescalada,项目名称:go-KX3-panadapter,代码行数:20,代码来源:main.go

示例15: Run

func Run(paths []string) {
	// initialize audio
	portaudio.Initialize()
	defer portaudio.Terminate()

	audio := NewAudio()
	if err := audio.Start(); err != nil {
		log.Fatalln(err)
	}
	defer audio.Stop()

	// initialize glfw
	if err := glfw.Init(); err != nil {
		log.Fatalln(err)
	}
	defer glfw.Terminate()

	// create window
	glfw.WindowHint(glfw.ContextVersionMajor, 2)
	glfw.WindowHint(glfw.ContextVersionMinor, 1)
	window, err := glfw.CreateWindow(width*scale, height*scale, title, nil, nil)
	if err != nil {
		log.Fatalln(err)
	}
	window.MakeContextCurrent()

	// initialize gl
	if err := gl.Init(); err != nil {
		log.Fatalln(err)
	}
	gl.Enable(gl.TEXTURE_2D)

	// run director
	director := NewDirector(window, audio)
	director.Start(paths)
}
开发者ID:jxwufan,项目名称:nes,代码行数:36,代码来源:run.go


注:本文中的github.com/gordonklaus/portaudio.Terminate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。