fmod(1001.0, 0.0001)
给出0.00009999999995
,考虑到 的预期结果,这似乎是一个非常低的精度 (10 -5 ) 0
。
根据cppreference,fmod()
可以使用 来实现remainder()
,但是remainder(1001.0, 0.0001)
给出了-4.796965775988316e-14
(距离double
精度还很远,但比 10 -5好得多)。
为什么fmod
精度如此依赖输入参数?正常吗?
MCVE:
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
double a = 1001.0, b = 0.0001;
cout << setprecision(16);
cout << "fmod: " << fmod(a, b) << endl;
cout << "remainder: " << remainder(a, b) << endl;
cout << "actual: " << a-floor(a/b)*b << …
Run Code Online (Sandbox Code Playgroud) 一直在忙着用FMOD进行C#游戏开发,我很早就遇到了麻烦,我似乎无法绕过.我想做一些分支音频的东西并将一些游戏动作同步到节拍等等,所以我尝试将同步点添加到我的音乐曲目中.这是代码:
public class Music
{
private Sound music;
private Channel channel;
private IntPtr syncPtr;
public string File { get; private set; }
public Music(string file)
{
File = file;
}
public void Load()
{
music = new Sound();
Audio.System.createSound(File, MODE.HARDWARE, ref music);
}
public void Unload()
{
music.release();
}
public virtual void Play()
{
Audio.System.playSound(channel == null ? CHANNELINDEX.FREE : CHANNELINDEX.REUSE, music, false, ref channel);
music.addSyncPoint(500, TIMEUNIT.MS, "wooo", ref syncPtr);
channel.setCallback(channelCallback);
}
private RESULT channelCallback(IntPtr channelraw, CHANNEL_CALLBACKTYPE type, IntPtr commanddata1, …
Run Code Online (Sandbox Code Playgroud) 我的项目是一个独立的C++应用程序,它使用FMOD播放声音.我以前使用Visual Studio 2010开发了相同的项目没有任何问题,但是2012年给了我一个经典错误:"程序无法启动,因为你的计算机缺少fmodex.dll.请尝试重新安装程序来解决这个问题. " 该项目似乎加载其他DLL(如Direct3d相关文件和d3d着色器编译器)就好了.
只有在尝试从IDE调试或运行程序时,才会出现此问题,而不是将可执行文件复制到具有DLL的相应目录并手动运行.如果从程序中删除对FMOD的所有引用,则调试和运行正常.我确保我在项目设置中有正确的工作目录(除了它在同一目录中加载所有其他文件).我最初从Visual Studio 2010转换了项目,但试图从头开始创建一个新项目,没有运气.我也修改了所有可能的编译器和链接器设置,谷歌搜索似乎也没有帮助.
我猜这个问题与新的Metro风格的应用程序有关,它是处理外部依赖的方法,但我也关闭了"Metro风格应用程序支持".我开始认为我已经尽力而为,不知道下一步该尝试什么.获取更多诊断信息的方向也将非常受欢迎!谢谢!
编辑:我正在使用的Visual Studio版本是Visual Studio Ultimate 2012 RC,版本11.0.50706.0 QRELRC 2012年7月
所以,我正在使用FMOD api,它确实是一个C api.
不是那个坏或什么的.它只是它与C++代码没有良好的接口.
例如,使用
FMOD_Channel_SetCallback( channel, callbackFunc ) ;
Run Code Online (Sandbox Code Playgroud)
它想要一个C风格的函数callbackFunc
,但我想传递一个类的成员函数.
我最终使用Win32技巧,使成员函数静态.然后它作为FMOD的回调.
现在我必须破解我的代码以使一些成员静态,只是为了解释FMOD的C-ness.
我想知道它是否可能在FMOD中或者是否有解决方法将回调链接到特定C++对象的实例成员函数(不是静态函数).它会更顺畅.
我正在使用FMOD开发一个应用程序,当用户单击Next/Prev按钮时,该应用程序将立即从包含语音的MP3文件开始播放下一个/上一个句子的录音.我通过调用Sound :: lock获得了mp3文件的PCM数据,但是Sound :: getFormat只告诉我它是"16位整数PCM数据",不知道它是签名还是未签名.我怎么知道的?
互联网上的一些文章称,几乎所有16位整数PCM数据都已签名.如果我的PCM数据被签名,那么什么范围的值表示静默,那些值接近0(例如-10~10),或接近-32768(例如-32768~-32750)?如果它们是接近0的值,这是否意味着相对数字之间的含义没有区别,如-32767和32767?
我需要检测足够长的静音,例如长于500毫秒,以确定语音中每个句子的开始位置.
谁能给我任何关于如何检测句子之间的沉默的建议?
我是C编程的新手,我之前没有使用Visual Studio或第三方库.我正在尝试使用FMOD做一些简单的事情并且需要链接fmodvclib
,fmod.h
当然fmod.dll
.
我已经fmodex_vc.lib
在include和library目录以及其他包含库中添加了其他依赖项和低级库的路径,但是当我构建它时,它给了我:
"cannot open source file "fmod.h"
identifier "FSOUND_SAMPLE" is undefined
Cannot open include file: 'fmod.h': No such file or directory
Run Code Online (Sandbox Code Playgroud)
但即使是奇怪的是:
cannot open source file "stdio.h"
Run Code Online (Sandbox Code Playgroud)
这是代码:
#include "fmod.h"
#include <stdio.h>
FSOUND_SAMPLE* handle;
int main(void)
{
int input;
FSOUND_Init(44100, 32, 0);
handle = FSOUND_Sample_Load(0, "test.ogg", 0, 0, 0);
FSOUND_PlaySound(0, handle);
while (input != 0)
{
scanf_s("&d", &input);
}
FSOUND_Sample_Free(handle);
FSOUND_Close();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
我在C#中使用FMOD.我已经尝试fmodex.dll
通过选择Project-> Add Reference并浏览来导入文件fmodex.dll
,但是我收到一个错误:
无法添加对...的引用.请确保该文件是可访问的,并且它是有效的程序集或COM组件
它是可访问的,但我仍然得到错误.我阅读了指南,它说使用fmodex_vc.lib
链接到fmodex.dll
文件时.所以我尝试,但我似乎无法找到如何链接到Visual Studio中的.lib文件; 搜索Google总是引导我链接到.dll文件.
我正在尝试通过网址加载视频,但我仍然遇到同样的错误.我正在使用Unity 5.3和http://docs.unity3d.com/ScriptReference/WWW-movie.html中的示例代码(由于当前示例未编译,因此进行了大量修改).
using UnityEngine;
using System.Collections;
// Make sure we have gui texture and audio source
[RequireComponent (typeof(GUITexture))]
[RequireComponent (typeof(AudioSource))]
public class TestMovie : MonoBehaviour {
string url = "http://www.unity3d.com/webplayers/Movie/sample.ogg";
WWW www;
void Start () {
// Start download
www = new WWW(url);
StartCoroutine(PlayMovie());
}
IEnumerator PlayMovie(){
MovieTexture movieTexture = www.movie;
// Make sure the movie is ready to start before we start playing
while (!movieTexture.isReadyToPlay){
yield return 0;
}
GUITexture gt = gameObject.GetComponent<GUITexture>();
// Initialize gui texture …
Run Code Online (Sandbox Code Playgroud) 我在FMOD示例文件夹中找到了一个名为nativeactivity的示例,但不幸的是它使用了一些java代码:
package org.fmod.nativeactivity;
public class Example extends android.app.NativeActivity
{
static
{
System.loadLibrary("fmodex");
System.loadLibrary("main");
}
}
Run Code Online (Sandbox Code Playgroud)
Android.mk看起来像这样:
LOCAL_PATH := $(call my-dir)
#
# FMOD Ex Shared Library
#
include $(CLEAR_VARS)
LOCAL_MODULE := fmodex
LOCAL_SRC_FILES := libfmodex.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/inc
include $(PREBUILT_SHARED_LIBRARY)
#
# Example Library
#
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := main.c
LOCAL_LDLIBS := -llog -landroid
LOCAL_SHARED_LIBRARIES := fmodex
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
Run Code Online (Sandbox Code Playgroud)
没有java部分可以吗?如果是这样,我需要改变什么?
我正在尝试编译一个链接到 Eclipse C/C++ IDE 中的 FMOD 库的程序。我什至没有包含任何库的标头,我只将共享库添加到项目依赖项中,并且出现以下链接错误:
Building target: Adventum
Invoking: GCC C++ Linker
g++-8 -L"/home/jkmcameron/Workplace/git/Adventum/Adventum/libs/GLFW" -L"/home/jkmcameron/Workplace/git/Adventum/Adventum/libs/Python" -L"/home/jkmcameron/Workplace/git/Adventum/Adventum/libs/FMOD" -o "Adventum" ./src/adventum/graphics/Display.o ./src/adventum/Main.o ./src/adventum/ScriptLoader.o -lglfw3 -lpython3.8 -lfmodL -ldl -lpthread -lX11 -lvulkan
/usr/bin/ld: /home/jkmcameron/Workplace/git/Adventum/Adventum/libs/FMOD/libfmodL.so: .dynsym local symbol at index 2 (>= sh_info of 2)
/usr/bin/ld: /home/jkmcameron/Workplace/git/Adventum/Adventum/libs/FMOD/libfmodL.so: .dynsym local symbol at index 3 (>= sh_info of 2)
/usr/bin/ld: /home/jkmcameron/Workplace/git/Adventum/Adventum/libs/FMOD/libfmodL.so: .dynsym local symbol at index 4 (>= sh_info of 2)
Finished building target: Adventum
Run Code Online (Sandbox Code Playgroud)
查找并.dynsym local symbol at index ...
没有给我带来任何线索,即使我将范围扩展到 FMOD 库之外并查找该错误,一般来说,我在谷歌上没有看到很多关于它的点击,就好像该错误是为不便而量身定制的我。这不应该是二进制文件的问题,因为我已经尝试了 …
fmod ×10
c++ ×5
c ×2
c# ×2
android-ndk ×1
audio ×1
delegates ×1
dll ×1
eclipse-cdt ×1
include-path ×1
linker ×1
linux ×1
pcm ×1
precision ×1