- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 PulseAudio 的新手。我正在尝试制作简单的程序。一个人会录制声音并将其保存在 baniry 文件中,另一个人应该打开它并播放。这是我的录制代码:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#define BUFSIZE 32
int main(int argc, char*argv[])
{
/* The Sample format to use */
static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE, //16bit iqneba agwerili tito sample
.rate = 44100, //number of samples played in each second
.channels = 2
};
pa_simple *s_in = NULL;
int ret = 1;
int error;
int siri =0;
//file info
FILE* pFile;
char* yourFilePath = "xma.bin";
pFile = fopen(yourFilePath,"wb");
if (!(s_in = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error)))
{
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
goto finish;
}
for (;siri<10000;siri+=1)
{
uint8_t buf[BUFSIZE];
ssize_t r;
int yorBufferSize = strlen(buf) + 1;
/* Write your buffer to disk. */
if (pa_simple_read(s_in, buf, sizeof(buf), &error) < 0)
{
fprintf(stderr, __FILE__": read() failed: %s\n", strerror(errno));
goto finish;
}
if (pFile)
{
fwrite(buf, yorBufferSize, 1, pFile);
puts("Wrote to file!");
}
else
{
puts("Something wrong writing to File.");
}
}
ret = 0;
finish:
if (s_in)
pa_simple_free(s_in);
return ret;
fclose(pFile);
}
这是我的录音程序:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#define BUFSIZE 32
int main(int argc, char*argv[])
{
/* The Sample format to use */
static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE, //16bit iqneba agwerili tito sample
.rate = 44100, //number of samples played in each second
.channels = 2
};
pa_simple *s_out = NULL;
int ret = 1;
int error;
//file info
FILE* pFile;
char* yourFilePath = "xma.bin";
pFile = fopen(yourFilePath, "rb");
/* Create a new playback stream */
if (!(s_out = pa_simple_new(NULL, argv[0], PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error)))
{
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
goto finish;
}
for (;;)
{
uint8_t buf[BUFSIZE];
fread(buf, sizeof(buf), 1, pFile);
ssize_t r;
if(feof(pFile))
{
break;
}
printf("%x", buf);
/* ... and play it */
if (pa_simple_write(s_out, buf, sizeof(buf), &error) < 0)
{
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error));
goto finish;
}
}
/* Make sure that every single sample was played */
if (pa_simple_drain(s_out, &error) < 0)
{
fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", pa_strerror(error));
goto finish;
}
ret = 0;
finish:
if (s_out)
pa_simple_free(s_out);
return ret;
fclose(pFile);
}
记录程序中的For循环只是为了记录一些东西的时间(无法弄清楚如何设置计时器),我知道我不应该使用goto,但它是出于教育目的(PulseAudio网站上提供的示例)。我尝试了 xma.bin 的十六进制转储,它给了我完全不同的输出比 printf("%x", buf); 基本上 printf 只会重复返回 bf9fe15c 并且发出烦人的声音。希望你能帮忙。谢谢。
最佳答案
我从录制程序中删除了pa_simple_drain()(这是我在录制程序中使用此函数的错误)函数,现在它可以工作了。但在 printf("%x", buf) 中,它仍然一次又一次地给我返回相同的十六进制值。但程序效果很好。有人可以解释为什么它打印相同的值吗?
关于c - PulseAudio:录制声音但播放烦人的声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33777417/
我使用我的gentoo作为kvm的主机操作系统,通过vga直通在Windows上播放,但我的声音有问题,质量不好,我听到声音中有裂纹。我在主机操作系统上使用pulseaudio(带有--system模
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我是 PulseAudio 的新手。我正在尝试制作简单的程序。一个人会录制声音并将其保存在 baniry 文件中,另一个人应该打开它并播放。这是我的录制代码: #ifdef HAVE_CONFIG_H
在 Ubuntu 15.10 中使用 pulseaudio,我想将两个不同的麦克风组合成一个接收器,并让它们在两个不同的输出上播放组合输出。下面的脚本完成了第一部分(在网上找到的),但输出似乎只在单个
我需要使用一些 documented pulseaudio options for ffmpeg比如设备。文档中的示例有效,但仅设置流名称: ffmpeg -i INPUT -f pulse "str
两者的输出 pactl list sink-inputs和 pacmd list-sink-inputs包含一个属性部分: Properties: media.name = "ALSA Pla
我正在尝试使用 PulseAudio“实时”捕获麦克风信号。该程序是用 C 语言编写的,并使用 PulseAudio Simple API。不幸的是我请求的音频缓冲区不包含任何信号。要么我的代码有问题
我对脉冲音频和 alsa 完全陌生。情况是这样的: 我已经为 alsa 编译了 mpd。这是嵌入式系统,mpd 的脉冲音频插件不可用。 当我不启动脉冲音频时,mpd 使用 alsa 运行良好 一旦我启
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
面对奇怪的 PulseAudio 监控设备(即播放发送到扬声器的声音的音频输入设备)行为。我已根据 PulseAudio 文档 https://freedesktop.org/software/pul
他。 该程序应不断检查来自蓝牙麦克风的传入声音。蓝牙设备可以随时连接/断开连接。 如何从 Pulseaudio 获取源列表发生变化的事件? 我试着用pa_context_set_event_callb
我通过查看各种示例编写了这段代码:Python pulseaudio monitor , Pavumeter source , async playback example , 和 Pacat sou
我想为pulseaudio的几个客户端读出此刻播放的音频音量。 我想解决的问题如下:我正在 xmms 中听音乐,然后暂停,听 friend 在 youtube 上发给我的歌曲。一个小时后,我突然发现我
我正在为 Maemo/MeeGo 开发移动应用程序,Maemo 使用 PulseAudio。我想给来电者播放 mp3(并在播放时取消麦克风,而不是听来电者,一切都应该在后台完成),为此,我必须从某个(
我有一个使用 KVM 的 Windows 10 专业版虚拟机。它是通过 virt-manager 使用最新版本的 libvirt 和 QEMU 设置的。所有这些都在 Manjaro Linux 20
尝试设置 LibGDX 时,我在 IntelliJ 中遇到此错误。我正在运行 PopOS(基于 Ubuntu)。有什么帮助吗? ALSA lib ../../pulse/pulse.c:242:(pu
我正在尝试从我的 docker 容器中发出声音。我正在使用 Ubuntu 20.10 开发 Raspberry4。 启动容器时,我使用以下行来挂载声音文件文件夹: -v /tmp/pulseaudio
我希望pulseaudio(远程实例)将发送到主要alsa设备的音频通过互联网直接推送到RTP,以便我可以在家用计算机上的VLC上收听它。 在我的/etc/pulse/default.pa load-
使用我的智能手机,我可以通过Raspbery pi上的蓝牙流音乐(我使用脉冲音频)。我现在想录制这首歌或将这首歌直接放在GNU RADIO的“音频”源中。 ALSA/Pulse audio captu
我正在尝试将 raspbmc(在 Raspberry Pi 模型 b 上运行)的默认音频输出记录到原始 wav 流(我想将其通过管道传输到 piFM 以将音频传输到 FM 调谐器)。我没有成功使用 a
我是一名优秀的程序员,十分优秀!