我正在尝试让一个使用Crystal的音频播放器。互联网表明,portaudio是播放音频的最佳C库,并且由于没有原生的Crystal库,它似乎是最好的选择。
有人已将大部分工作用于将portaudio API绑定到Crystal,但该项目已过时,似乎已被Crystal更新破坏。我认为修复别人的绑定会比从头开始做更容易。
这是一个不必要的长篇介绍。当我尝试编译crystal-portaudio
时,我收到以下错误:
$ crystal src/portaudio.cr ~/sw/crystal/crystal-portaudio (master)
Error in src/portaudio.cr:1: while requiring "./portaudio/*"
require "./portaudio/*"
^
in src/portaudio/device.cr:2: while requiring "./host_api"
require "./host_api"
^
in src/portaudio/host_api.cr:5: can't use instance variables at the top level
delegate :device_count, :default_input_device, :default_output_device, :type, @info
^~~~~
答案 0 :(得分:3)
以下是使用Crystal 0.22编译和运行public editHandler({ dataItem }): void {
let clients: IClientContract[];
let environments: IEnvironmentContract[];
this.clientWebApiService.getClients()
.flatMap((clientsResult: any): Observable<IEnvironmentContract[]> => {
clients = clientsResult as IClientContract[];
console.log('1', clients);
return this.environmentWebApiService.getEnvironmentsNotInPipeline();
})
.flatMap((environmentResult: IEnvironmentContract[]): any => {
environments = environmentResult;
console.log('2', environments);
})
.subscribe(() => {
console.log('3');
let editableDeploymentItem: IDeployableEnvironmentForm = this.deployableEnvironmentContractMapperService
.mapDeployableEnvironmentContractToDeployableEnvironmentForm(
dataItem,
clients,
environments);
console.log('4', editableDeploymentItem);
this.editDeployment = editableDeploymentItem;
this.isNew = false;
});
}
和crystal spec
的最小补丁,但是碎片似乎还需要更多的工作才能真正实现。
crystal samples/list.cr