Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-27 Thread Thomas Huth

On 25/03/2023 18.24, Christian Schoenebeck wrote:

On Friday, March 24, 2023 8:38:25 PM CET Frank Carmickle wrote:

Greetings all,

Thank you Thomas for bringing this to the attention of folks who are in the 
know.

Thank you, Christian for explaining.

What I am finding is that qemu sets the host to 44.1k even though alsa dmix in 
the guest is set to 48k. What I wanted was to set the host to 96k and the guest 
to 96k. When I do that, by using audio midi setup for the host, and changing 
alsa dmix rate to 96k, after starting the guest, audio midi setup shows that 
the host is set to 44.1k.

When using the parameter Thomas mentioned, the host sample rate is changed to 
the designated.

Seems like alsa has a problem. I'll use Thomas's suggestion as a workaround, 
for now.


DMIX in ALSA is like mixengine in QEMU: a layer that automatically converts
audio format on the fly between incompatible sides (sample rate, channels,
etc.). That's used if the audio hardware does not support the desired audio
format natively.

You did not mention which audio frontend (the virtual audio hardware emulated
by QEMU for guest) you are using. I just made a quick test with the AC97
frontend and `aplay` a wav file on guest, and it used 48 kHz like the wav file
content, not 44.1 kHz.

@Thomas: I just realized that QEMU's audio frontend selection parameters are
not documented at all?


Yes, as I said, the documentation is really lacking here - I had to look at 
the sources to come up with the out.frequency=48000. I think if someone who 
knows the audio stuff in QEMU comes up with a patch for the documentation, 
that would be really appreciated.


 Thomas




Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-25 Thread Volker Rümelin

Am 24.03.23 um 13:04 schrieb Christian Schoenebeck:

On Friday, March 24, 2023 8:54:35 AM CET Thomas Huth wrote:

On 23/03/2023 21.03, Frank Carmickle wrote:

Greetings all,

Every time a qemu instance is run, the host systems audio hardware sample rate 
is set to 44.1khz. Is it possible to change this behavior, and if so, how?

   Hi,

not sure if I've got the question right, and I'm not an expert when it comes
to QEMU audio, but I think you can set the playback frequency like this for
example:

   qemu-system-x86_64 --audiodev alsa,id=a1,out.frequency=48000

... but seems like the QEMU documentation is really lacking here, so I might
be wrong. Maybe Christian, Gerd or Marc-André could correct me in that case
(now on CC:).

By default host's audio backend is opened with audio parameters requested by
guest. So if guest requests 44.1 kHz then host's audio system is opened with
44.1 kHz as well (if supported by host's audio system that is).


Hi Christian,

I have a small correction. Your description above is correct for 
in|out.fixed-settings=off or in|out.mixing-engine=off. This is not the 
default.


By default most audio backends open a 44100Hz, signed 16bit stereo audio 
stream. CoreAudio ignores stream format options and JACK Audio and Spice 
ignore stream format and sample rate options.


With best regards,
Volker


By supplying out.frequency=x you can override host's sample rate, but as guest
apparently requested 44.1 kHz before, guest would probably still use 44.1 kHz
and QEMU would resample the audio stream to the requested host's sample rate.

So the question is what you really want to achieve. Maybe it would be better
to force guest using the desired sample rate instead.

Best regards,
Christian Schoenebeck









Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-25 Thread Christian Schoenebeck
On Friday, March 24, 2023 8:38:25 PM CET Frank Carmickle wrote:
> Greetings all,
> 
> Thank you Thomas for bringing this to the attention of folks who are in the 
> know.
> 
> Thank you, Christian for explaining.
> 
> What I am finding is that qemu sets the host to 44.1k even though alsa dmix 
> in the guest is set to 48k. What I wanted was to set the host to 96k and the 
> guest to 96k. When I do that, by using audio midi setup for the host, and 
> changing alsa dmix rate to 96k, after starting the guest, audio midi setup 
> shows that the host is set to 44.1k.
> 
> When using the parameter Thomas mentioned, the host sample rate is changed to 
> the designated.
> 
> Seems like alsa has a problem. I'll use Thomas's suggestion as a workaround, 
> for now.

DMIX in ALSA is like mixengine in QEMU: a layer that automatically converts
audio format on the fly between incompatible sides (sample rate, channels,
etc.). That's used if the audio hardware does not support the desired audio
format natively.

You did not mention which audio frontend (the virtual audio hardware emulated
by QEMU for guest) you are using. I just made a quick test with the AC97
frontend and `aplay` a wav file on guest, and it used 48 kHz like the wav file
content, not 44.1 kHz.

@Thomas: I just realized that QEMU's audio frontend selection parameters are
not documented at all?






Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-24 Thread Frank Carmickle
Greetings all,

Thank you Thomas for bringing this to the attention of folks who are in the 
know.

Thank you, Christian for explaining.

What I am finding is that qemu sets the host to 44.1k even though alsa dmix in 
the guest is set to 48k. What I wanted was to set the host to 96k and the guest 
to 96k. When I do that, by using audio midi setup for the host, and changing 
alsa dmix rate to 96k, after starting the guest, audio midi setup shows that 
the host is set to 44.1k.

When using the parameter Thomas mentioned, the host sample rate is changed to 
the designated.

Seems like alsa has a problem. I'll use Thomas's suggestion as a workaround, 
for now.

Thank you,
--FC

> On Mar 24, 2023, at 08:04, Christian Schoenebeck  
> wrote:
> 
> On Friday, March 24, 2023 8:54:35 AM CET Thomas Huth wrote:
>> On 23/03/2023 21.03, Frank Carmickle wrote:
>>> Greetings all,
>>> 
>>> Every time a qemu instance is run, the host systems audio hardware sample 
>>> rate is set to 44.1khz. Is it possible to change this behavior, and if so, 
>>> how?
>> 
>>  Hi,
>> 
>> not sure if I've got the question right, and I'm not an expert when it comes 
>> to QEMU audio, but I think you can set the playback frequency like this for 
>> example:
>> 
>>  qemu-system-x86_64 --audiodev alsa,id=a1,out.frequency=48000
>> 
>> ... but seems like the QEMU documentation is really lacking here, so I might 
>> be wrong. Maybe Christian, Gerd or Marc-André could correct me in that case 
>> (now on CC:).
> 
> By default host's audio backend is opened with audio parameters requested by
> guest. So if guest requests 44.1 kHz then host's audio system is opened with
> 44.1 kHz as well (if supported by host's audio system that is).
> 
> By supplying out.frequency=x you can override host's sample rate, but as guest
> apparently requested 44.1 kHz before, guest would probably still use 44.1 kHz
> and QEMU would resample the audio stream to the requested host's sample rate.
> 
> So the question is what you really want to achieve. Maybe it would be better
> to force guest using the desired sample rate instead.
> 
> Best regards,
> Christian Schoenebeck
> 
> 




Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-24 Thread Thomas Huth

On 23/03/2023 21.03, Frank Carmickle wrote:

Greetings all,

Every time a qemu instance is run, the host systems audio hardware sample rate 
is set to 44.1khz. Is it possible to change this behavior, and if so, how?


 Hi,

not sure if I've got the question right, and I'm not an expert when it comes 
to QEMU audio, but I think you can set the playback frequency like this for 
example:


 qemu-system-x86_64 --audiodev alsa,id=a1,out.frequency=48000

... but seems like the QEMU documentation is really lacking here, so I might 
be wrong. Maybe Christian, Gerd or Marc-André could correct me in that case 
(now on CC:).


 HTH,
  Thomas




Re: qemu modifies host audio sample rate with coreaudio backend to 44.1khz on startup

2023-03-24 Thread Christian Schoenebeck
On Friday, March 24, 2023 8:54:35 AM CET Thomas Huth wrote:
> On 23/03/2023 21.03, Frank Carmickle wrote:
> > Greetings all,
> > 
> > Every time a qemu instance is run, the host systems audio hardware sample 
> > rate is set to 44.1khz. Is it possible to change this behavior, and if so, 
> > how?
> 
>   Hi,
> 
> not sure if I've got the question right, and I'm not an expert when it comes 
> to QEMU audio, but I think you can set the playback frequency like this for 
> example:
> 
>   qemu-system-x86_64 --audiodev alsa,id=a1,out.frequency=48000
> 
> ... but seems like the QEMU documentation is really lacking here, so I might 
> be wrong. Maybe Christian, Gerd or Marc-André could correct me in that case 
> (now on CC:).

By default host's audio backend is opened with audio parameters requested by
guest. So if guest requests 44.1 kHz then host's audio system is opened with
44.1 kHz as well (if supported by host's audio system that is).

By supplying out.frequency=x you can override host's sample rate, but as guest
apparently requested 44.1 kHz before, guest would probably still use 44.1 kHz
and QEMU would resample the audio stream to the requested host's sample rate.

So the question is what you really want to achieve. Maybe it would be better
to force guest using the desired sample rate instead.

Best regards,
Christian Schoenebeck