INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Thoughts on a loopback workaround (automatic loopback for games and netflix)  (Read 10463 times)

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

I have an active system using JRiver as my crossover. As a result, all computer sound has to pass through JRiver to come out of my speakers, so I use loopback constantly.  I also really love theater-view and am gradually trying to consolidate all the things I use my HTPC for into JRiver's theater view.  There are two main obstacles: Netflix and Video games.

To get Netflix, or video games, or the steam client to work in my set up I need loopback running (Netflix ignores JRiver's audio output settings, DSP, etc.).  At the moment, I can't really use theater view for anything requiring loopback without a lot of alt-tabbing around, which basically defeats the purpose of launching any of those things in theater view.  For example, if I set loopback, and then launch a video game from theater view, JRiver disables my loopback, so I have to navigate back to JRiver to re-set the loopback. So I mostly switch out of theater view, and then launch netflix and games externally so I can set loopback in advance.  

It's all perfectly doable (and I'm thankful to be able to do it at all), but it makes the system more complicated for the family to use, and slightly disrupts the "seamlessness" of theater-view on a HTPC.  So I was thinking about it, and I wondered if one could just run two instances of JRiver:

Instance #1: outputs to the "real" output sound device connected to the amp and speakers, and is set perpetually to loopback on startup.  This instance would have all your DSP etc.

Instance #2: set to output to your default audio device so that the outputs of this player get picked up by the loopback of the 1st instance.  This instance would be your "Front-end" where you would choose what to play, etc.  It could stay in theater view for all media.  

Is there any reason that anyone can think of why that wouldn't work as a workaround?  Would the increase in latency be a killer? I'll probably try it this weekend (when I have more time to fiddle) and report back on my results.  If anyone is using a similar set up, please chime in.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

So I tried setting this up tonight, and after some fiddling it works more or less as expected.  I haven't been able to suss out a way to get the PC to boot into the dual JRiver configuration, but I figure that's just a matter of putting some time in on learning the command line parameters.

I started two JRiver instances after enabling multiple instances in "advanced settings".  Here are the other settings I used:

1st JRiver instance: this instance uses my normal settings and is set to play loopback.  The output device is my normal soundcard that is connected to my speakers.  I use my normal zones, normal zone DSP, and output settings.  The only difference is that I set the internal volume to my reference level and leave it there.

2nd JRiver instance: In this instance I made a new zone which I'll use for playing media and controlling volume.  In the new zone, I set my output device to my default system soundcard (the one I normally use for loopback).  The output mode is regular WASAPI with minimal buffers, but you need to uncheck the "open device for exclusive access" box or the first instance of JRiver won't be able to grab the stream (I couldn't figure out why playback kept failing until I unchecked that box).  The output format is set for source sample rate, source bitdepth, and source number of channels (after all it's just a pass through), and the only DSP I enabled here is volume leveling. 

Once that was set up with loopback going in the first instance, everything I played in the second instance worked as expected.  Audio and Video played as usual and I didn't notice any unusual latency.  But more importantly, I could launch netflix and the steam fullscreen client from theater view with full sound and no (additional) fiddling. 

So once I figure out how to get this set up as a default boot state, I'll have a "loopback by default" set up and can leave the HTPC in theater view for easy family use.  It's kind of a fiddly setup and may present unforeseen problems, but I've at least got a proof of concept.  I'll report back if I identify any problems.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608

Cool.  Thanks for working on this.

Yell if you need help scripting the startup sequence.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

Cool.  Thanks for working on this.

Yell if you need help scripting the startup sequence.

So I've been having some trouble on the start up sequence.  Specifically, I'm having a hard time getting two instances of JRiver to load.  My method was to copy the first registry startup entry and modify the command line, but I just wind up with one instance when I boot.  I think I understand the command line parameters, I just can't seem to get it to load twice on start up.  To be fair, I haven't done serious start up manipulation in a Microsoft OS since autoexec.bat and config.sys.  I could easily write a batch file that would do it (I remember the syntax), but I'm not sure batch files are even still a thing in windows.  I guess I've seen some batch to .exe converters, but my guess is that there's a much easier way to be doing this, and I'm not too proud to ask for help!

In the "good news" category, I tested the set up in some "high intensity" situations and learned a few more settings quirks.  Specifically I watched a Blu-Ray and played Skyrim (launched from the steam client, which was launched from JRiver).  Everything worked correctly.  Sound was synced, and I noticed no significant degradation of performance.  With all the settings turned up to Ultra in Skyrim, I got a little occasional framerate decrease, but I always get a little framerate dropping on Ultra, and "High" ran smooth as silk.  So neither latency nor the additional processor load appear to be a problem in my system (your mileage may vary, for reference, my JRMark is in the low 4,000's on a good day).  It appears that even videoclock continues to work correctly* (but see below).

Some little tweaks:  

1) Make sure you don't have adaptive volume on in both places or you can get strange results.
2) You'll (sadly) need to turn off autoplay for CDs/DVDs/Blu Rays; otherwise both instances will fight to try and play them, and
3) I couldn't get the MADVR OSD to appear while playing the Blu Ray no matter what I did.  I tried changing the key configuration, doing it when JRiver had focus (and when it didn't), when MADVR's control panel was up, tried different windowed and exclusive modes, everything I could think of.  That may just be a more general glitch though, as I can no longer see the OSD even when one instance is running.  The OSD was working four days ago, so I have no idea what's up with that, but I thought I'd report a potentially related glitch.  That also prevents me from reporting authoritatively on Blu Ray performance.  All I can say is that sound appeared to be perfectly synced and I couldn't see any dropped frames, etc.

Some "Bigger Picture" Thoughts:

I'm not a software developer (which should be obvious), but this seems to suggest that the JRiver folks could potentially implement what is essentially virtual-sound-device-like functionality without going to the trouble of creating a WDM driver, i.e. by just by creating a tray widget that's effectively a duplicate instance of JRiver that only loops back, but still allows DSP/audio output tinkering/etc.  In addition to providing most of the functionality of a "proper" virtual sound output device, it would also allow for some DSP functions that currently cannot be accomplished in JRiver.  For example, to bring up a previous issue I had, I can make dialogue more audible by boosting the center channel volume by a custom amount before the 5.1 gets downmixed to 2.1 because I have two bites at the output format with PEQ in between.  

Thinking it through, the only problem (that I can think of) that a WDM driver would solve that a "tray widget" approach would not solve would be the use-case of folks who don't have a second disconnected sound card to send the loopback to.  I'm not sure if that's an enormous problem or a non-problem.  Most of the frequenters of this forum seem to have either a USB DAC, an internal soundcard, or are bitstreaming to a receiver.  In most of those cases there's an unused MoBo soundcard literally built right in.  But I can imagine there may be a significant number of less vocal folks who don't have a "dead" device for loopback.  

I'm mostly just thinking out loud.  I'm still kind of in awe of the fact that JRiver will tolerate (and function correctly) even in pretty "off-label" uses, like the one I'm experimenting with.  Once again, I'm extremely grateful for the flexibility and stability offered by the software.  The devs are doing impressive work.
Logged

JustinM

  • World Citizen
  • ***
  • Posts: 117

Cool.  Thanks for working on this.


+1



I also have an active (JRiver) setup..
 This is an interesting option ,, which I hope helps the JRiver delopement team continue to support HTPCs
Logged

natehansen66

  • World Citizen
  • ***
  • Posts: 239

This is a cool idea. Do you use a remote? I wonder if both instances would pick up the remote commands and change the volume, for example, in both instances.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

This is a cool idea. Do you use a remote? I wonder if both instances would pick up the remote commands and change the volume, for example, in both instances.

I do use a remote, but haven't tried to use it for volume control in this setup yet (it seems to work for navigating theater view).  It'll be easy to fix if there's a zone-specific way to set remote settings, or if there's a way to set the remote so it only works when JRiver has focus (as only one instance will have focus at a time), although that approach could have other problems.  

One work-around I'm pretty sure would work (and would probably be easiest and best for this problem) would be to set the loopback instance-zone's volume to "disabled," and leave the "front-end" on internal volume.  Then I'd expect that only one would be adjusted by the remote.  I'll test that tonight and see if it works.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

This is a cool idea. Do you use a remote? I wonder if both instances would pick up the remote commands and change the volume, for example, in both instances.

Welp, the remote situation is kind of bizarre.  I had noticed in the past that some remote functions only worked for me when JRiver had focus (pause, play, the direction keys), but others worked regardless of whether JRiver had focus (volume control, the stop button).  I wasn't sure if that was by design or some accident of my hardware set up.  

Curiously, with my double instance set up, the commands that previously required focus work exactly right.  I can navigate theater view, press ok or play to start a file playing, or pause a file from theater view and nothing is disturbed in the other instance.  The "focussy" remote commands only affect the instance I'm looking at.

The "focus-less" remote commands are more interesting.  Volume control and the stop button only affect one instance, and consistently affect that instance, it appears to be based on load order: the first instance to load gets the "focus-less" remote controls and the other one ignores them.  This seems to be true even when the second instance is "in focus."  So this seems to be a self-correcting problem (at least based on my limited testing).  

Once I get the start up scripting working, I'll just need to make sure that the instance I plan to use as the "front-end" is loaded first.  

EDIT: I tried doing batch file scripting with the command line, but no dice.  JRiver's MC18.exe command line won't launch a second instance.  The "usual" JRiver executable doesn't seem to take command line parameters, so I think I'm dead in the water on this as a start up "fire and forget" solution.  If anybody has any ideas, I'd be glad to hear them; otherwise it works pretty well.
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101

I realise this is an old thread, but I just wanted to say thank you for this idea. I set up a batch file over the weekend that loads two instances of MC19 (one with loopback) so that all sounds on my computer go through MC.

There are a few quirks. I think this is partly because I'm running a fairly slow computer. The library opens in read only mode, because I'm running the two instances on the same library (I think installing a separate portable install may solve this - ie. so two separate libraries are being accessed). I couldn't set my WASAPI settings to "non-exclusive" mode, so loopback is just using Directsound at the moment (I'm not looping back any high quality audio so this is probably OK). Also, the command line set volume function doesn't seem to work reliably in this configuration for some reason (I'm trying to set the volume in a loopback 'zone' so I don't have to worry about adjusting it later on - again a portable install may solve this problem). I'll keep playing around and see if I can improve the performance etc. If anyone is interested I would be happy to post the batch file and any of the other settings I have used.

I agree with your comment on the 'tray widget' approach. I think a stripped down version of MC accessible from the tray/launching at startup could work as an alternative to a WDM driver in these circumstances.

Thanks again.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient

I realise this is an old thread, but I just wanted to say thank you for this idea. I set up a batch file over the weekend that loads two instances of MC19 (one with loopback) so that all sounds on my computer go through MC.

There are a few quirks. I think this is partly because I'm running a fairly slow computer. The library opens in read only mode, because I'm running the two instances on the same library (I think installing a separate portable install may solve this - ie. so two separate libraries are being accessed). I couldn't set my WASAPI settings to "non-exclusive" mode, so loopback is just using Directsound at the moment (I'm not looping back any high quality audio so this is probably OK). Also, the command line set volume function doesn't seem to work reliably in this configuration for some reason (I'm trying to set the volume in a loopback 'zone' so I don't have to worry about adjusting it later on - again a portable install may solve this problem). I'll keep playing around and see if I can improve the performance etc. If anyone is interested I would be happy to post the batch file and any of the other settings I have used.

I agree with your comment on the 'tray widget' approach. I think a stripped down version of MC accessible from the tray/launching at startup could work as an alternative to a WDM driver in these circumstances.

Thanks again.

I would be very interested to see your batch file as I could never get two instances to launch at start up (admittedly this was in MC18, maybe things have changed?).  Please share, it would be neat to get this working.

A few thoughts/suggestions:

1) When you say you couldn't get your WASAPI settings to non-exclusive mode, do you mean that you don't have the "open device for exclusive access" check box or that unchecking it didn't work?

2) If you're having trouble with the volume, the way I fixed it was using the zone method I described above.  If volume protection isn't enabled and the startup volume options are unchecked, zones will stay at the volume setting you last set them to (i.e. if I leave zone 2 at 75%, it's at 75% when I next start JRiver, even if I changed the volume in other zones).  If you that doesn't work, in the worst case you can just set the volume mode in the loopback zone to "disable" and then it will always be the same.  Ideally you'd never want the loopback zone's volume to change, so you should be able to set it and forget it.
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101

Thanks for the response. I'm sorry I've taken a while to respond. I'm really still playing around with this setup and it's proving a little problematic. My batch file is as follows (with some comments):

@ECHO OFF
ECHO Start MC Loopback
TIMEOUT /T 130 <----This line is just to allow my computer to boot up completely.
mc19.exe /LibraryReadOnly <---- So the second instance is able to write to the library.
TIMEOUT /T 5
mc19.exe /Mode Standard
mc19.exe /Play live://loopback <---- Loopback is set to play in its own zone (like your setup I think).
ECHO Minimise MC
mc19.exe /MCC 10014
ECHO Start MC Theatre View
TIMEOUT /T 5
"C:\Program Files (x86)\J River\Media Center 19\Media Center 19.exe"

In answer to your questions:
(1) For some reason MC19 cannot play my files unless 'open device for exclusive access' is ticked. I get a dialogue popping up advising that the computer can't play the file.
(2) I had volume protection enabled, so I think that was the problem.

I'm having a problem at the moment, which I think relates to the exclusive access issue. The loopback works initially (eg if I play some web based video using the default sound card) and then if I play for example a flac file (through MC19) any sound from the default sound card stops being received in the loopback instance. It will play again if I bring up the loopback instance and start and stop playback.

Anyway, hope the batch file helps someone.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient


I'm having a problem at the moment, which I think relates to the exclusive access issue. The loopback works initially (eg if I play some web based video using the default sound card) and then if I play for example a flac file (through MC19) any sound from the default sound card stops being received in the loopback instance. It will play again if I bring up the loopback instance and start and stop playback.

Anyway, hope the batch file helps someone.


Thanks a million for the batch file.  I'm going out of town today, but I'll try it when I get home.  You're correct that your problem is related to the exclusive access issue, and it's very strange that it refuses to play back without it.  I had an identical problem until I disabled "open for exclusive access" on the playing instance.  What happens is that when the "play instance" seizes exclusive access of the default soundcard it (necessarily) boots out anything else trying to interact with the soundcard, including the JRiver instance that's looping back. 

Have you tried also disabling event style along with exclusive access? Have you a tried a different output mode to see if that helps? 
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re:
« Reply #12 on: October 24, 2013, 05:04:25 pm »

I've just tried disabling event style and it seems to work on non exclusive access ok. Interestingly I can't play live loop back on this setting (it comes up with 'something went wrong with playback'). I'll keep testing.
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re:
« Reply #13 on: November 08, 2013, 06:10:38 am »

After a couple of weeks of testing I think I'm generally happy with the configuration. I've had to set any 'live' media (the loopback zone and tv) to play through direct sound. My high resolution audio refuses to play without exclusive access /event style enabled. I think these are both issues with the DAC (I have an AudioGd nfb 2, which uses a Tenor Te7022 usb interface). The other issue I have is with the autoplay for CD and DVD which confuses the loopback instance (this isn't a problem for me, because I don't play CDs or DVDs very often - nearly everything is on the hard disk. I'm currently playing Spotify through JRiver (controlled with spotimote on my phone) and it works very well.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient
Re:
« Reply #14 on: November 08, 2013, 08:43:04 am »

After a couple of weeks of testing I think I'm generally happy with the configuration. I've had to set any 'live' media (the loopback zone and tv) to play through direct sound. My high resolution audio refuses to play without exclusive access /event style enabled. I think these are both issues with the DAC (I have an AudioGd nfb 2, which uses a Tenor Te7022 usb interface). The other issue I have is with the autoplay for CD and DVD which confuses the loopback instance (this isn't a problem for me, because I don't play CDs or DVDs very often - nearly everything is on the hard disk. I'm currently playing Spotify through JRiver (controlled with spotimote on my phone) and it works very well.

I had to turn off autoplay entirely when I was running two instances.  I'm glad you got it working to your satisfaction though  ;D

So I'm not sure why it didn't occur to me before, but I realized last night that given how mature zones have become, this could be setup in one instance with two zones.  

I just tried doing it in a single instance of JRiver using two different zones that aren't connected to each other and it worked great without any of the weirdness (one zone looping back, the other zone outputting to the default sound device without taking exclusive control).  So all I need to do is launch JRiver, start loopback in one zone and then switch focus to the other zone.   That's actually pretty seamless and resolves all the remote control/autoplay weirdness.  

If anyone is curious about the exact configuration, let me know and I'll lay out how I currently have it set up.

Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101

Thanks - that's a great suggestion. I think I've managed to successfully configure my setup in the same way now (I've reconfigured my batch file above to start loopback and then launch theater view). I've had to set up a separate zone to deal with the playback of HD Audio (which uses WASAPI Exclusive/Event style) and I've added a loopback button in theater view that allows me to reset loopback without exiting theater view. Seems to work pretty well. Thanks again!
Logged

Bister

  • Member
  • *
  • Posts: 1
Re:
« Reply #16 on: December 03, 2013, 04:41:22 am »

Hello,
This sounds exactly like what I'm looking for! Could You share Your setup?

/Magnus


I had to turn off autoplay entirely when I was running two instances.  I'm glad you got it working to your satisfaction though  ;D

So I'm not sure why it didn't occur to me before, but I realized last night that given how mature zones have become, this could be setup in one instance with two zones.  

I just tried doing it in a single instance of JRiver using two different zones that aren't connected to each other and it worked great without any of the weirdness (one zone looping back, the other zone outputting to the default sound device without taking exclusive control).  So all I need to do is launch JRiver, start loopback in one zone and then switch focus to the other zone.   That's actually pretty seamless and resolves all the remote control/autoplay weirdness.  

If anyone is curious about the exact configuration, let me know and I'll lay out how I currently have it set up.


Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5239
  • "Linux Merit Badge" Recipient
Re:
« Reply #17 on: December 03, 2013, 07:53:03 am »

Hello,
This sounds exactly like what I'm looking for! Could You share Your setup?

/Magnus



I'm going to assume that you understand how loopback works and that you've already gotten loopback working in it's normal use.  If not let me know, and I'll back up and explain. 

I'm not at home so I won't be able to post the batch file until tonight, but here's the basics:
1) You'll need to make a new zone.  I recommend copying an existing zone that has working playback.
2) Configuration for the new zone or "loopback zone":  This zone should use your normal output settings and is set to play loopback.  The output device is my "good" soundcard that is connected to my speakers.  In this zone, I use my normal DSP (except volume levelling) and output settings.  The only difference is that I set the internal volume to my reference level (as loud as I'd want it, but no louder) and leave it there.
3) Configuration for your existing zone or "player zone": in your old zone you should set your output device to use WASAPI on your default system soundcard (the one you normally use for loopback, not the one connected to your speakers).  In the mode configuration you should disable event style and uncheck the "open device for exclusive access" box or the first instance of JRiver won't be able to grab the stream.  The output format in DSP studio is set for source sample rate, source bitdepth, and source number of channels (after all it's just a pass through), and the only DSP I enabled in this zone is volume leveling (volume levelling needs to be enabled in the "player" zone. 

Once you have that setup, start loopback in the "loopback zone" and then switch to the "player zone" and you're done.  You can play music in JRiver, play a youtube clip in a browser, etc.  It's not perfect, and has some quirks, e.g. you might have to fiddle with the buffer settings to get the lipsync right, and the volume of web content can be very loud (which requires switching to the loopback zone to adjust the volume), but that configuration should work in a basic way.  It requires a lot of fiddling, if you're looking for a "fire and forget" solution, this may not be it.

When I get home, I'll post the batch file I run on startup to automatically turn this all on.
Logged
Pages: [1]   Go Up