GithubHelp home page GithubHelp logo

moutend / go-wca Goto Github PK

View Code? Open in Web Editor NEW
106.0 3.0 27.0 195 KB

Pure golang bindings for Windows Core Audio API. The `cgo` is not required.

License: MIT License

Go 99.53% Makefile 0.47%
windows audio wasapi

go-wca's Introduction

go-wca

MIT License

Pure golang bindings for Windows Core Audio API. The cgo is not required.

Features

  • Rendering audio with shared timer driven mode.
  • Rendering audio with event driven mode.
  • Capturing audio with shared timer driven mode.
  • Capturing audio with event driven mode.
  • Loopback capturing with shared timer mode.
  • Loopback capturing with shared event mode.
  • Change volume of master or each channels.
  • Change volume of individual applications.
  • Hook audio device events.

If you're not familiar with Windows Core Audio API, visit the MSDN.

Prerequisites

  • Go 1.13 or later

Usage

The examples are located in _example directory. It helps you to learn how the interfaces can be used.

If you want to build all examples at once, run the command below:

make all VERSION=latest

Then the executables are generated in bin directory.

Documentation

Each APIs in this package correspond to native COM APIs, so that you can refer the documentation on MSDN as a full documentation of this package.

The following list contains the links to the documentation of native API which is available in this package.

Contributing

  1. Fork (https://github.com/moutend/go-wca/fork)
  2. Create a feature branch
  3. Add changes
  4. Run go fmt
  5. Commit your changes
  6. Open a new Pull Request

Author

Yoshiyuki Koyanagi [email protected]

LICENSE

MIT

go-wca's People

Contributors

darkmetalmouse avatar emarj avatar medusalix avatar moutend avatar thiefmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-wca's Issues

Cannot install the package

This is a problem with v0.2.0 but not with v0.1.2

What version of Go are you using (go version)?

go version go1.14.1 windows/amd64

What operating system and processor architecture are you using (go env)?

windows 10 x64

What did you do?

Tried to go get the package

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

that the package was gotten

What did you see instead?

can't load package: package github.com/moutend/go-wca: cannot find package "github.com/moutend/go-wca" in any of:
c:\go\src\github.com\moutend\go-wca (from $GOROOT)
C:\Users\jacks\go\src\github.com\moutend\go-wca (from $GOPATH)

problem building app

Hello ,

What version of Go are you using (go version)?
image

What operating system and processor architecture are you using (go env)?
image

What did you do?
I'm using go-wca inside persona project

I use Visual studio code as IDE

but in the building phase go build -o bin/hello I got:

What did you expect to see?
app build without problem

What did you see instead?
go: finding module for package github.com/moutend/go-wca
....\pkg\mod\github.com\talkkonnect\[email protected]\volume_windows.go:8:2: module github.com/moutend/go-wca@latest found (v0.2.0), but does not contain package github.com/moutend/go-wca

thanks in advance

IAudioMeterInformationVtbl struct order of uintptr is incorrect for GetChannelsPeakValues and GetMeteringChannelCount

What version of Go are you using (go version)?

go 1.21.1 amd64

What did you do?

This is the 0.3.0 VTable for the IAudioMeterInformation interface, I had failures in trying to get channel counts and corresponding peak values, when I realized the VTable had wrong orders for those two pointers (they're inverted).

I checked by making the syscall by myself and it works, I had E_POINTER errors on calling GetMeteringChannelCount and panic errors on calling GetChannelsPeakValues

type IAudioMeterInformationVtbl struct {
	ole.IUnknownVtbl
	GetPeakValue            uintptr
	GetChannelsPeakValues   uintptr
	GetMeteringChannelCount uintptr
	QueryHardwareSupport    uintptr
}

The working VTable:

type IAudioMeterInformationVtbl struct {
	ole.IUnknownVtbl
	GetPeakValue            uintptr
	GetMeteringChannelCount uintptr
	GetChannelsPeakValues   uintptr
	QueryHardwareSupport    uintptr
}

I've simply worked around it by making the syscall by myself, I don't know if it's simply because I'm using Windows 10 (?)

IMMDevice GetId panics due to a memory access violation

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.15.7

What operating system and processor architecture are you using (go env)?

Windows 10 (20H2) / amd64

What did you do?

package main

import (
	"fmt"
	"log"

	"github.com/go-ole/go-ole"
	"github.com/moutend/go-wca/pkg/wca"
)

func main() {
	err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED)
	if err != nil {
		log.Fatal(err)
	}
	defer ole.CoUninitialize()

	var mmde *wca.IMMDeviceEnumerator
	if err = wca.CoCreateInstance(wca.CLSID_MMDeviceEnumerator, 0, wca.CLSCTX_ALL, wca.IID_IMMDeviceEnumerator, &mmde); err != nil {
		return
	}
	defer mmde.Release()

	var mmd *wca.IMMDevice
	if err = mmde.GetDefaultAudioEndpoint(wca.ERender, wca.EConsole, &mmd); err != nil {
		return
	}
	defer mmd.Release()
	var defaultDevID string
	if err = mmd.GetId(&defaultDevID); err != nil {
		return
	}

	fmt.Println(defaultDevID)
}

What did you expect to see?

A valid device ID

What did you see instead?

unexpected fault address 0x376c6910
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0x376c6910 pc=0x2afe55]

goroutine 1 [running]:
runtime.throw(0x2d9240, 0x5)
	F:/Go/src/runtime/panic.go:1116 +0x79 fp=0xc0000c9df8 sp=0xc0000c9dc8 pc=0x225f19
runtime.sigpanic()
	F:/Go/src/runtime/signal_windows.go:249 +0x24f fp=0xc0000c9e28 sp=0xc0000c9df8 pc=0x2379af
github.com/moutend/go-wca/pkg/wca.mmdGetId(0x25b376af920, 0xc0000c9f20, 0xc0000c9f10, 0x0)
	D:/Dev/go/src/github.com/moutend/go-wca/pkg/wca/IMMDevice_windows.go:60 +0xd5 fp=0xc0000c9ec8 sp=0xc0000c9e28 pc=0x2afe55
github.com/moutend/go-wca/pkg/wca.(*IMMDevice).GetId(...)
	D:/Dev/go/src/github.com/moutend/go-wca/pkg/wca/IMMDevice.go:36
main.main()
	D:/Dev/go/src/github.com/thiefmaster/audiotarget/main.go:30 +0x1c9 fp=0xc0000c9f88 sp=0xc0000c9ec8 pc=0x2b1969
runtime.main()
	F:/Go/src/runtime/proc.go:204 +0x209 fp=0xc0000c9fe0 sp=0xc0000c9f88 pc=0x2286c9
runtime.goexit()
	F:/Go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc0000c9fe8 sp=0xc0000c9fe0 pc=0x254c81

The panic happens in this line: u := *(*uint16)(unsafe.Pointer(uintptr(start) + 2*uintptr(i))) of mmdGetId

Example: muting microphone

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.14

What operating system and processor architecture are you using (go env)?

Windows 10 64-bit 2004

Hello, I came across your library and I was wondering if you have an example of muting the microphone. I see that the examples are all about output devices but none are about input devices. Thank you!

> Figure out how to handle IMMNotificationClient

Figure out how to handle IMMNotificationClient

from some testing, the code itself seems to work on some events:

  • OnPropertyValueChanged
  • OnDefaultDeviceChanged

I changed the code a bit, waiting 10 minutes using time.After with select.

I think that maybe the issue that the sound card does not detect the changes, but still investigating that idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.