有人可以解释一下snd_pcm_writei
snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer,
snd_pcm_uframes_t size)
Run Code Online (Sandbox Code Playgroud)
作品?
我像这样使用它:
for (int i = 0; i < 1; i++) {
f = snd_pcm_writei(handle, buffer, frames);
...
}
Run Code Online (Sandbox Code Playgroud)
http://pastebin.com/m2f28b578上的完整源代码
这是否意味着,我不应该给出snd_pcm_writei()
所有帧的数量buffer
,而只是
sample_rate*latency = frames
?
因此,如果我有例如:sample_rate = 44100 latency = 0.5 [s] all_frames = 100000
帧的,我应该给的数目snd_pcm_writei()
是
sample_rate*latency = frames 44100*0.5 = 22050
以及for循环的迭代次数应该是多少?
(int)100000/22050 = 4; 框架= 22050
还有一个,但只有
100000 mod 22050 = 11800
帧?
它是如何工作的?
路易丝
http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gf13067c0ebde29118ca05af76e5b17a9
谷歌新闻如何自动对新兴主题的文件进行分类和排名,如"奥巴马的2011年预算"?
我有一堆用棒球数据标记的文章,如球员名称和与文章的相关性(感谢,opencalais),并且很想创建一个谷歌新闻风格的界面,排列和显示新帖子,特别是新兴话题.我认为一个朴素的贝叶斯分类器可以用一些静态类别进行训练,但这并不能真正跟踪"这个球员刚刚被交易到这个球队,这些其他球员也参与了"的趋势.
请注意以下行为:
a = u"foo"
b = u"b\xe1r" # \xe1 is an 'a' with an accent
s = [a, b]
print a, b
print s
for x in s: print x,
Run Code Online (Sandbox Code Playgroud)
结果是:
foo bár
[u'foo', u'b\xe1r']
foo bár
Run Code Online (Sandbox Code Playgroud)
当我刚打印出两个值坐在变量a
和b
,我得到了我期待; 当我将字符串值放在列表中并打印出来时,我得到了不需要的u"xyz"
形式; 最后,当我用循环打印列表中的值时,我再次获得第一个表单.有人可以解释这个看似奇怪的行为吗?我知道这可能是一个很好的理由.
假设语言的解释器(可以是从PHP到Ruby的任何东西)用C语言编写.如何变量(或更复杂的数据结构,不仅包含名称和值),这些变量由当前正在执行的脚本定义,存储并读出来?
由于我对C的了解很少,我最终得出的结论是,这只能用数组来完成.
// Variable type definition would go here
var* variables;
Run Code Online (Sandbox Code Playgroud)
该var
类型将包含两个字符串name
和value
.
好的.因此脚本定义例如:30个变量.现在,如果必须读出其中一个变量,那么函数getVar
(或类似的东西)必须遍历所有30个变量并将它们的name
s与所请求变量的名称进行比较.想象一下,有一个循环请求
我完全错了吗?如果是,(现代?)脚本语言如何处理变量?它们如何存储和读出?
在通过语法(PHP :)明确定义变量的语言中$myVar
,解释器可以在解析过程中用数值替换所有变量.(我是对的吗?)是这样的吗?
如果我在Win表单中有Checked列表框,我填写如下
List<Tasks> tasks = db.GetAllTasks();
foreach (var t in tasks)
tasksCheckedListBox.Items.Add(t.Name);
Run Code Online (Sandbox Code Playgroud)
如何迭代tasksCheckedListBox.Items并将一些复选框设置为已选中?
谢谢
我创建了一个名为foo_module.py
包含以下代码的文件:
import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
Run Code Online (Sandbox Code Playgroud)
在该文件旁边,我创建了一个名为foo_package
than 的目录,其中包含一个空__init__.py
文件和一个名为g.py
just 的文件:
class g:
pass
Run Code Online (Sandbox Code Playgroud)
现在,当我运行时,foo_module.py
我得到一个奇怪的错误消息:
Exception TypeError: "'NoneType' object is not callable" in ignored
但是,如果我将目录重命名foo_package
为foo
,并更改导入行foo_module.py
,我不会收到任何错误.Wtf在这里发生了什么?
在WinXP上运行Python 2.6.4.
好吧我正在从服务器下载文件,我计划删除在客户端下载后在服务器上下载的文件.
我的下载代码工作正常,但我不知道何时将命令删除该文件.
string filepath = restoredFilename.ToString();
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo myfile = new FileInfo(filepath);
// Checking if file exists
if (myfile.Exists)
{
// Clear the content of the response
Response.ClearContent();
// Add the file name and attachment, which will force the open/cancel/save dialog box to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.Name);
//Response.AddHeader("Content-Disposition", "inline; filename=" + myfile.Name);
// Add the file size into the response …
Run Code Online (Sandbox Code Playgroud) 有谁知道如何设置插入触发器,这样当从我的应用程序执行插入时,数据会被插入并且postgres返回,甚至在触发器完成执行之前?
我在下面的代码中通过g ++编译器得到了一些令人讨厌的分段错误.关于为什么会发生这种情况以及如何解决这个问题的任何想法都会很棒.
#include <iostream>
using namespace std;
class Base {
public:
Base() {}
virtual ~Base() {};
virtual int getNum(int) = 0;
};
class Derived: public Base {
public:
Derived() :
Base() {}
~Derived() {}
int getNum(int num) {
return num;
}
};
class Foo {
public:
Foo() {
};
void init() {
Derived n;
*baseId = n;
}
void otherStuff() {
cout << "The num is" << baseId->getNum(14) << baseId->getNum(15) << baseId->getNum(16) << baseId->getNum(15) << endl;
}
Derived* baseId;
}; …
Run Code Online (Sandbox Code Playgroud)