BananaHemic / Mumble-Unity

Performant Mumble Client For Unity3D
MIT License
78 stars 29 forks source link

how do I use this in my project? #1

Closed louisholley closed 7 years ago

louisholley commented 7 years ago

I can't seem to open it in unity, and am unsure as to how to otherwise use the files from the readme

BananaHemic commented 7 years ago

If you have git shell installed, you can navigate to your project directory's "Assets" folder. Then you can run git clone https://github.com/BananaHemic/Mumble-Unity.git

louisholley commented 7 years ago

Hey, thanks for the response. That seemed to work, but when I run the project I get:

DllNotFoundException: opus-1.3 Mumble.NativeMethods.opus_decoder_create (Int32 sampleRate, Int32 channelCount, Mumble.OpusErrors& error) (at Assets/Mumble-Unity/Scripts/NativeMethods.cs:125) Mumble.OpusDecoder..ctor (Int32 outputSampleRate, Int32 outputChannelCount) (at Assets/Mumble-Unity/Scripts/Opus/OpusDecoder.cs:62) Mumble.OpusCodec..ctor () (at Assets/Mumble-Unity/Scripts/Opus/OpusCodec.cs:11) Mumble.MumbleClient..ctor (System.String hostName, Int32 port, Mumble.DebugValues debugVals) (at Assets/Mumble-Unity/Scripts/MumbleClient.cs:83) MumbleTester.Start () (at Assets/Mumble-Unity/MumbleTester.cs:28)

I haven't changed any of the files, I just put the 3 objects in the example scene onto a player prefab that is spawned into the scene. Any clue what I'm doing wrong?

BananaHemic commented 7 years ago

Are on you on a Mac or iOS? The opus library might not work on those platforms right now.

I just cloned it into a new project and it appears to be working for me. However, I just pushed some commits to make it easier to get started. If you still have this issue, can you see if it happens in the Example.unity scene?

louisholley commented 7 years ago

Hey, thanks again for responding.

I'm on Mac. I've just started again; I cloned the repo into Assets, loaded in the example scene, changed the hostname, port, and password on the MumbleTester attached to the Mumble game object so they matched my server. When I run it, I get the same error as before: DllNotFoundException: opus-1.3

Is this because I'm using a Mac? Is there any way for me to go about fixing this?

Really appreciate your help!

BananaHemic commented 7 years ago

I appreciate you trying out this asset!

The issue is that there isn't a Mac opus dll in this repo yet. To get one, someone would need to just compile the opus library for that platform. I'd do it, but I don't have a mac to test on yet

louisholley commented 7 years ago

Ah ok, well I'll give that a try today and let you know how it goes. Do I want to download the development binary build or the source code directly?

louisholley commented 7 years ago

I downloaded the source code and compiled it. In the readme it says "Once you have compiled the codec, there will be a opus_demo executable in the top directory". Do I use this opus_demo executable in place of the dll file? I noticed that there are a bunch of DllImport methods in the NativeMethods.cs file, so is this what I'm supposed to change?

BananaHemic commented 7 years ago

So, I've never actually built a library for Mac, but my understanding is that you compile it into a "bundle" containing both 32 and 64 bit architectures. I believe this needs to be done with XCode. You can then name this bundle "opus-1.3" and put it in the plugins folder. This is going to be different than the executable, and you won't need to make any changes to NativeMethods.cs

BananaHemic commented 7 years ago

Also, if you get it compiled, please make a PR as I'd love to add mac support for this!

louisholley commented 7 years ago

Hi, thanks for the help. I'm trying to build the bundle in Xcode and I'm getting this error: "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." Did you experience this at all when building the dll?

BananaHemic commented 7 years ago

Hmm, I didn't get that issue when I was building it in Visual Studio. The config.h header file should define "USE_ALLOCA" which should stop that error from happening. That's in the Win32 folder, so do you think it's possible that that header file isn't being added?

louisholley commented 7 years ago

I'm not sure, I took out the line throwing the error just to see if I could build it anyway and I'm getting loads more errors. Not sure if this will work with Xcode, so I'm looking at alternative routes to building bundles. Specifically this but the Opus makefile is quite complicated for my understanding!

louisholley commented 7 years ago

So I have actually got it to build into a .bundle now, but I've put it in the Plugins folder and am still getting the "DllNotFoundException". Any clue what could be wrong?

louisholley commented 7 years ago

Ah - I don't think it built right. I'll keep trying. What a pain!

BananaHemic commented 7 years ago

Let me know if there's anyway I can help! I had the same frustration when compiling opus the first time.

I think your best bet is to stick to Xcode and find a way to add the config.h file. I'd do it, but I don't have macOS.

louisholley commented 7 years ago

Thanks, I appreciate the offer. All of the files are there, it's just Xcode is not well documented and is very cumbersome. You would think replacing the default build process with running ./configure and make would be simple, but alas! I've sought help on stack overflow, will let you know if I get anywhere.

louisholley commented 7 years ago

I've just learned that there's no magic to .bundle files, they are just directories with specific structures. Which means that essentially, I can take the Info.plist that Xcode creates and put it into a folder with the right structure, and then just compile the codec without Xcode and drag and drop whatever it compiles to into the corresponding folder, allegedly. I've noticed that after I run make, an 'opus_demo' file is created. Is this the executable, so to speak, that would be used by the plugin?

I tried dragging and dropping this opus_demo into the .bundle folder; Unity seems to accept that it is a plugin but when I run I still get the DllNotFoundException :(

BananaHemic commented 7 years ago

What does the opus_demo folder structure look like? The plugin should be some libraries, not an executable. Also, don't forget to name the bundle "opus-1.3"

louisholley commented 7 years ago

I've got somewhere, I just had to change all of the build settings in Xcode and tell it where to look for header files etc. In the linking options, if I use the Mach-O Type "static library", it actually builds fine; however, it doesn't work in Unity. If I use the Mach-O Type "bundle", which I assume is what we want, I get these errors.

louisholley commented 7 years ago

you'll never guess what BananaHemic... A colleague of mine suggested doing brew install opus, and renaming the libopus.0.dylib to opus-1.3.bundle, and it actually works.... I'm slightly in dismay, although overjoyed that the problem is finally solved. In any case, do you want me to send you this .bundle somehow (dropbox?) so you can add it to the repo and claim support for os x also? :)

BananaHemic commented 7 years ago

Congratulations! That's fantastic news.

Ideally, it'd be nice for you to make a pull request with that plugin (I can help you with this if needed). Otherwise, dropbox would work as well.

louisholley commented 7 years ago

Do I need to be authorised to make a pull request? I'm not quite sure how to do it as I haven't done it before.

louisholley commented 7 years ago

Also, would it be possible to have some hints as to how to get user input from the microphone? The mumbletester script is working with my server, as in playing the example clip, but how do I get it to send the microphone input? Thanks so much for all the help by the way!

BananaHemic commented 7 years ago

To make a pull request:

  1. Make a fork (there's a button in the top right of the repo's Github page)
  2. Clone your fork, using git
  3. Add the bundle to your forked repo, commit and push your changes
  4. Open your forked repo in Github, and click on "New pull request"

You can use the microphone instead of the example clip by leaving all the debugging parameters unchecked in MumbleTester, especially the "use synthetic source" variable. Also make sure that "Always Send Audio" in MumbleMicrophone is enabled.

louisholley commented 7 years ago

Cool, I think that's done! I hope I did it right. Again, thank you so much for all your help.

louisholley commented 7 years ago

Ah! Sorry to be a pain, I've got the "use synthetic source" unchecked, the rest of the debugging options are unchecked too, and it's still playing the audio clip on the mumble server rather than using microphone input. Any ideas why this might be happening?

BananaHemic commented 7 years ago

Huh, that's strange. Are you using the example scene? Is there only one of the following scripts in the scene:

I just tested it out on an empty project, and it was using the microphone correctly (although I did just add a fix for some other microphone issues). My only guess is that maybe there's a second script somewhere that's sending the "TestingClipToUse" audio data

louisholley commented 7 years ago

I just redownloaded from scratch and it's working now! I can't thank you enough :)