Comments (12)
Yeah should be done and checked in next week
from mixedrealitytoolkit-unity.
@andymule Looks like maybe we've got a couple implementations here. Reasons to wait on yours or should @stbertou just make a PR?
from mixedrealitytoolkit-unity.
Hey guys, didn't see all this talk until now. There are official PRs out on this repo and a matching one going into the main Holotoolkit. It should all be good to go everywhere. Please use excessively and make changes as you see fit. Cheers!
from mixedrealitytoolkit-unity.
@andymule are you working on this currently?
from mixedrealitytoolkit-unity.
Great news !
On Friday last week I gave it a quick go, here is the c# bindings that seem to work except for MicGetFrame that I ignored.
You probably have done that already anyway but just in case here it is:
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace HoloToolkit.Unity
{
public class MicStreamSelector
{
#region Public APIs
public static int MicInitialize(int category, int fftsize, int numBuffers, int samplerate)
{
return DLLImports.MicInitialize(category, fftsize, numBuffers, samplerate);
}
public static int MicStartStream(bool keepData)
{
return DLLImports.MicStartStream(keepData);
}
public static int MicStopStream()
{
return DLLImports.MicStopStream();
}
public static int MicStartRecording(String filename)
{
return DLLImports.MicStartRecording(filename);
}
public static int MicPause()
{
return DLLImports.MicPause();
}
public static int MicResume()
{
return DLLImports.MicResume();
}
public static int MicSetGain(float gain)
{
return DLLImports.MicSetGain(gain);
}
public static int MicDestroy()
{
return DLLImports.MicDestroy();
}
#endregion
#region Internal
/// <summary>
/// Raw MicStreamSelector.dll imports
/// </summary>
private class DLLImports
{
[DllImport("MicStreamSelector")]
public static extern int MicInitialize(
[In] int category,
[In] int fftsize,
[In] int numBuffers,
[In] int samplerate);
[DllImport("MicStreamSelector")]
public static extern int MicStartStream(
[In] bool keepData);
[DllImport("MicStreamSelector")]
public static extern int MicStopStream();
[DllImport("MicStreamSelector")]
public static extern int MicStartRecording(
[In] String filename);
[DllImport("MicStreamSelector")]
public static extern int MicStopRecording(
[In] String path);
/*
[DllImport("MicStreamSelector")]
public static extern int MicGetFrame(// float *
[In] int length,
[In] int numchannels
);
*/
[DllImport("MicStreamSelector")]
public static extern int MicPause();
[DllImport("MicStreamSelector")]
public static extern int MicResume();
[DllImport("MicStreamSelector")]
public static extern int MicSetGain(
[In] float gain);
[DllImport("MicStreamSelector")]
public static extern int MicDestroy();
}
#endregion
}
}
from mixedrealitytoolkit-unity.
Here is a new version kindly improved by Dave Sullivan here in London
using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
#if NETFX_CORE
using Windows.Storage;
#endif
namespace HoloToolkit.Unity
{
public class MicStreamSelector
{
public enum ErrorCode
{
ALREADY_RUNNING = -10,
NO_AUDIO_DEVICE,
NO_INPUT_DEVICE,
ALREADY_RECORDING,
GRAPH_NOT_EXIST,
CHANNEL_COUNT_MISMATCH,
FILE_CREATION_PERMISSION_ERROR,
NOT_IMPLEMENTED = -1,
SUCCESS = 0
}
#region Public APIs
public static ErrorCode MicInitialize(int category, int fftsize, int numBuffers, int samplerate)
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicInitialize(category, fftsize, numBuffers, samplerate);
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicStartStream(bool keepData)
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicStartStream(keepData);
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicStopStream()
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicStopStream();
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicStartRecording(String filename)
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicStartRecording(filename);
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicStopRecording(ref String filename)
{
#if NETFX_CORE
string originalFilename = filename;
IntPtr msgBuffer = Marshal.AllocHGlobal(256);
try
{
Marshal.WriteByte(msgBuffer, 0);
DLLImports.MicStopRecording(msgBuffer);
filename = Marshal.PtrToStringAnsi(msgBuffer);
}
finally
{
Marshal.FreeHGlobal(msgBuffer);
}
//Debug.LogFormat("New audio filename is {0}", filename);
//filename = System.IO.Path.Combine(KnownFolders.MusicLibrary.Path, filename);
var fileInfo = new FileInfo(filename);
if (fileInfo.Exists)
{
return ErrorCode.SUCCESS;
}
return ErrorCode.FILE_CREATION_PERMISSION_ERROR;
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicPause()
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicPause();
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicResume()
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicResume();
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicSetGain(float gain)
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicSetGain(gain);
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
public static ErrorCode MicDestroy()
{
#if NETFX_CORE
return (ErrorCode)DLLImports.MicDestroy();
#else
return ErrorCode.NOT_IMPLEMENTED;
#endif
}
#endregion
#region Internal
/// <summary>
/// Raw MicStreamSelector.dll imports
/// </summary>
private class DLLImports
{
[DllImport("MicStreamSelector")]
public static extern int MicInitialize(
[In] int category,
[In] int fftsize,
[In] int numBuffers,
[In] int samplerate);
[DllImport("MicStreamSelector")]
public static extern int MicStartStream(
[In] bool keepData);
[DllImport("MicStreamSelector")]
public static extern int MicStopStream();
[DllImport("MicStreamSelector")]
public static extern int MicStartRecording(
[In] String filename);
[DllImport("MicStreamSelector")]
public static extern void MicStopRecording(
[In] IntPtr path);
/*
[DllImport("MicStreamSelector")]
public static extern int MicGetFrame(// float *
[In] int length,
[In] int numchannels
);
*/
[DllImport("MicStreamSelector")]
public static extern int MicPause();
[DllImport("MicStreamSelector")]
public static extern int MicResume();
[DllImport("MicStreamSelector")]
public static extern int MicSetGain(
[In] float gain);
[DllImport("MicStreamSelector")]
public static extern int MicDestroy();
}
#endregion
}
}
from mixedrealitytoolkit-unity.
Thanks for this, Dave and Stephane. The MicStream code is still under some internal development, so I’m not sure how much of the changes will make it into HoloToolkit, but we’ll look at it. In particular, I’m not sure why it’s returning NOT_IMPLEMENTED when you’re not running NETFX_CORE, as the code works fine running in the Unity editor on Windows 10, and having the code run in the Unity editor makes development much easier.
from mixedrealitytoolkit-unity.
I'll let @DaveSullivanAtWork comment here but he told me the DLL was somehow not working from within the editor
from mixedrealitytoolkit-unity.
@DanHolbert mind if I clean up your comment? It's full of the reply text from the email and is cluttering up this thread.
from mixedrealitytoolkit-unity.
Done. I didn't realize that email replies were generating GitHub comments.
Regarding the DLL not working in editor, I know it's been under some revision lately. It's possible some of the revision addressed this, although I'd lean toward not. @DaveSullivanAtWork, do you have any details on what wasn't working?
from mixedrealitytoolkit-unity.
@andymule is this done? Can we get a PR?
from mixedrealitytoolkit-unity.
from mixedrealitytoolkit-unity.
Related Issues (20)
- RegisteredServiceProvider HOT 1
- Object Instantiated inside GridObjectCollection of ScrollingObjectCollection with opposite rotation HOT 1
- Screen cant move with my head HOT 1
- Sample Scene Issues HOT 2
- Apply settings MRTK gives error about menu in mixed reality/project/apply HOT 5
- Pointers disappear when the scale of a gameObject with a "NearInteractionTouchableUnityUI" is zero HOT 4
- Tracking Lost Service is not behaving correctly HOT 5
- Object Manipulator with XR Socket Interactor HOT 2
- Controllers, Hands and Passthrough not working on MKRT2 when using OpenXR on Quest HOT 2
- Extended Delay in Launching Hololens Application HOT 1
- Unable to get MRTK Toolbox HOT 1
- Interactive Ability between Python Script and Unity HOT 1
- Lighting Scene is not taking effect in Scene system HOT 1
- Eye Tracking not working when enabled HOT 1
- Vertical FOV drop makes CameraFOVChecker.cs result incorrect HOT 1
- How to access Events "OnToggled" and "OnUntoggled" of a PressableButton? HOT 1
- PressableButton creates glow only for left hand HOT 1
- The self-built app deployment was successful, but it failed to run on the HoloLens 2. HOT 1
- mrtk3 bug HOT 2
- Mixed Reality Feature Tool crash when click start HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixedrealitytoolkit-unity.