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

[Question/Clarification request] How to play a stream and - on a button click - a short sound file simultaneously - withouc jackd? #247

Closed
Wikinaut opened this issue Mar 20, 2023 · 2 comments

Comments

@Wikinaut
Copy link

In issue #126 you describe how to run several players, basically so

import mpv
import time

p1=mpv.MPV()
p1.play("http:/.....")

time.sleep(10)
p2=mpv.MPV()
p2.play("file-beep.wav")

On my Raspberry Pi, I only get this working after jackd -R -dalsa having running, but using this approach I have to add

p1.ao="jack"
p2.ao="jack"

to the code above and (at the moment) I could not use the alsa equalizer plugin.

Question: Is there a programmatic way to run the two players to mix their signals?

@Wikinaut Wikinaut changed the title How to play a stream and - on a button click - a short sound file simultaneously - withouc jackd? [Question/Clarification request] How to play a stream and - on a button click - a short sound file simultaneously - withouc jackd? Mar 20, 2023
@Wikinaut
Copy link
Author

Wikinaut commented Mar 20, 2023

I found a solution using alsa, alsa equalizer and dmixer which I will publish here soon.

See

how to use multiple mpv-instances which audio signals are then mixed and finally equalised before they are sent to the DAC unit.

This is the core of my tweak:

mpvtest.py:

import mpv
options = { 'audio-output' : 'alsa/plugmixequal' } # plugmixequal as defined in .asoundrc
player1 = mpv.MPV( **options )
player2 = mpv.MPV( **options )

.asoundrc:

ctl.equal {
  type equal;
}

pcm.plugequal {
  type equal;
  slave {
    pcm "plughw:CARD=sndrpihifiberry,DEV=0";
  }
}

pcm.plugmixequal {
  type equal;
  slave {
	pcm plug:dmix;
  }
}

pcm.!default {
 type plug;
 slave {
   pcm plugequal;
 }
}

# Shared access to our audio card
pcm.dmixer {
	type dmix
	ipc_key 1234
	ipc_key_add_uid true
	ipc_perm 0666
	slave {
		pcm "hw:CARD=sndrpihifiberry,DEV=0";
	}
}

@Wikinaut
Copy link
Author

self-answered my question and fixed the issue.

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

No branches or pull requests

1 participant