到目前为止,我还没有找到任何关于如何为Stretch设置默认USB麦克风的指南,因此我遵循了Wheezy和Jessie的所有指南,但它们不起作用。
键入命令 package bullseye;
import javax.swing.JPanel; import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class BullsEye extends JPanel {
private JLabel label;
public BullsEye() {
setBackground(Color.white);
setPreferredSize(new Dimension(600,600));
for (int count = 0; count < 7; count++) {
int z=0;
z++;
label = new JLabel(Integer.toString(z));
label.setLocation(12, 32);
add(label,Color.white);
}
}
public void paintComponent(Graphics page) {
super.paintComponent(page);
Graphics2D g2 = (Graphics2D) page;
g2.setStroke(new BasicStroke(3));
//Graphics 2D is used to increase stroke of white ovals.
//As we place white ovals as draw (not fill), and not use draw command for black ovals.
//So, stroke of white ovals only increase to 3 from 1 (default value).
int x = 150, y = 150, diameter = 300;
for (int count = 0; count < 7; count++) {
page.setColor(Color.white);
page.drawOval(x, y, diameter, diameter);
page.setColor(Color.black);
page.fillOval(x, y, diameter, diameter);
diameter = diameter-50;
x = x+25;
y = y+25;
}
page.setColor(Color.white);
page.fillOval(300-(10/2), 300-(10/2) , 10 , 10);
//Centre of frame is 300, 300. But oval starts its first point from 300, 300.
//As dimensions of oval are 10, 10. So, it means they have diametre of 10, 10 and radius of 5.
//So, from this we know centre is at 300-5, 300-5.
x = 250/2; y = 250/2; diameter = 350;
for (int count = 0; count < 3; count++){
page.setColor(Color.black);
page.drawOval(x, y, diameter, diameter);
diameter = diameter+50;
x = x-25;
y=y-25;
}
}
public static void main(String[] args) {
JFrame frame = new JFrame("Bullseye");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BullsEye panel = new BullsEye();
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true); }
}
不会记录麦克风中的任何内容。但是,如果我输入此命令,它将起作用arecord sound.wav
。
以下是我输入arecord -l </ p>时出现的内容
arecord -f cd -D hw:1,0 -d 10 sound.wav
我已编辑此文件/usr/share/alsa/alsa.conf并将值设置为此
**** List of CAPTURE Hardware Devices ****
card 1: Headset [Plantronics Headset], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
我还编辑了/ etc / asoundrc文件并将其更改为:
defaults.ctl.card 1
defaults.pcm.card 1
和此:
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}
ctl.!default {
type hw
card 0
}
它仍然不起作用。
答案 0 :(得分:2)
我已经头痛这一天大约一天了,但我终于让它发挥了作用。
你的.asoundrc实际上应该是这样的:
pcm.!default {
type asym
playback.pcm "plughw:0"
capture.pcm "plughw:1"
}
ctl.!default {
type hw
card 1
}
否则您的设置没问题,但我认为此命令错误:
arecord sound.wav
测试麦克风(或至少适用于我的麦克风)的正确命令是:
arecord -D plughw:1,0 --duration=3 test.wav && aplay test.wav
此设置为3秒录制,录制停止后会自动播放给您(假设您的音频也有效)。 这部分 plughw:1,0 指向你的麦克风,我看到它设置为卡1。 我在您的测试期间创建了此文件 /etc/modprobe.d/alsa-base.conf ,请将其删除并重新启动。
sudo rm -f /etc/modprobe.d/alsa-base.conf
此外,如果您已经为AlexaPi项目尝试过此操作,请确保在尝试使用麦克风和音频之前停止服务。
sudo systemctl stop AlexaPi.service