Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record audio #8

Open
joeblew99 opened this issue Jun 6, 2017 · 9 comments
Open

record audio #8

joeblew99 opened this issue Jun 6, 2017 · 9 comments

Comments

@joeblew99
Copy link

here is a way to record audi for windows using the same dll sycall you use.
I also need to record audio on other OS's. Do you think that the same approach can be used for them ?

// Record Windows Audio project main.go
package main

import (
	"fmt"
	"log"
	"syscall"
	"time"
	"unsafe"
)

var (
	winmm         = syscall.MustLoadDLL("winmm.dll")
	mciSendString = winmm.MustFindProc("mciSendStringW")
)

func MCIWorker(lpstrCommand string, lpstrReturnString string, uReturnLength int, hwndCallback int) uintptr {
	i, _, _ := mciSendString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpstrCommand))),
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpstrReturnString))),
		uintptr(uReturnLength), uintptr(hwndCallback))
	return i
}

func main() {
	fmt.Println("winmm.dll Record Audio to .wav file")

	i := MCIWorker("open new type waveaudio alias capture", "", 0, 0)
	if i != 0 {
		log.Fatal("Error Code A: ", i)
	}

	i = MCIWorker("record capture", "", 0, 0)
	if i != 0 {
		log.Fatal("Error Code B: ", i)
	}

	fmt.Println("Listening...")

	time.Sleep(10 * time.Second)

	i = MCIWorker("save capture mic.wav", "", 0, 0)
	if i != 0 {
		log.Fatal("Error Code C: ", i)
	}

	i = MCIWorker("close capture", "", 0, 0)
	if i != 0 {
		log.Fatal("Error Code D: ", i)
	}

	fmt.Println("Audio saved to mic.wav")
}

@hajimehoshi
Copy link
Member

So you are suggesting a recording feature? My some random thoughts are:

  • Now oto implements Player which is io.Writer, so the newly introduced struct would be something which is io.Reader. That's interesting. Very consistent.
  • However, I don't see my use cases and I can't do dog-fooding. Is there any other people who want this feature? Is this high demand?
  • Besides io.Reader, there should be other configurations but I'm not familiar with this field.

@joeblew99
Copy link
Author

joeblew99 commented Jun 6, 2017 via email

@hajimehoshi
Copy link
Member

Well, I understood use cases, though I think this task still would be low priority... The actual oto user @faiface might have another idea.

@faiface
Copy link
Contributor

faiface commented Jun 6, 2017

I'd say this is a functionality which could be supported for completeness and the few use-cases. However, I agree it's low priority, very few games actually use sound recording, playing is much more useful. But eventually, if all other issues are resolved and there's nothing to do, recording wouldn't be a bad idea IMHO.

@joeblew99
Copy link
Author

I agree it's less useful. It's at least worth a shot since your going all in on the API restructuring.
If it's too hard can always bail on it for later version.

I am using Google cloud for NLP currentky. But bringing up an embedded version that will work on anything locally now. The Carnegie Mellon code is the current gold standard and so wrong a bridge from golang to the cpp code.
Will try to loop it into your stuff and integrate.

NLP may seem kind of silly but after working on 3 ML projects for games and being a total non believer in its usefulness I became a convert after seeing the pilot studies in house.
VR is also crying out for it because normal interaction systems using " meat sticks" fall apart pretty fast.

@hajimehoshi
Copy link
Member

I agree it's less useful. It's at least worth a shot since your going all in on the API restructuring.
If it's too hard can always bail on it for later version.

Adding this feature can be done anytime because this is new. Whether we are changing the API or not doesn't matter.

I am using Google cloud for NLP currentky. But bringing up an embedded version that will work on anything locally now. The Carnegie Mellon code is the current gold standard and so wrong a bridge from golang to the cpp code.
Will try to loop it into your stuff and integrate.
NLP may seem kind of silly but after working on 3 ML projects for games and being a total non believer in its usefulness I became a convert after seeing the pilot studies in house.
VR is also crying out for it because normal interaction systems using " meat sticks" fall apart pretty fast.

I understand that voice is useful and faster than other physical way because of human body's restriction, but I couldn't understand the other part... What is NLP? What is ML?

@joeblew99
Copy link
Author

NLP is how you interpret what a human says of types and route to to actual commands.

ML is machine learning in general.
NLP is a beach of MLP

@makew0rld
Copy link

https://github.com/MarkKremer/microphone exists, although it's aimed at working with the higher-level beep library, which uses oto.

@samborkent
Copy link

I would be very interested in a pure Go implementation for audio recording. For now it seems the smallest dependency is https://github.com/gen2brain/malgo which is build upon the miniaudio C library. It would be great to be able to record and playback audio with the same package without requiring cgo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants