我正在努力让新的AUParameterTree
和AUParameter
机制在我的Audio Unit V3测试项目中运行。问题是,当我从Host App获得对它的引用并更改其值时,Audio Unit扩展的参数似乎没有变化。
这是我的方法。
我正在使用新的Audio Unit V3 API。我在AUParameter
AUAudioUnit
initWithComponentDescription
中创建了 AUParameter *param1 = [AUParameterTree createParameterWithIdentifier:@"frequency"
name:@"Frequency"
address:frequencyAddress
min:500
max:5000
unit:kAudioUnitParameterUnit_Hertz
unitName:nil
flags:0
valueStrings:nil
dependentParameters:nil];
:
param1.value = 0.5;
设置默认值..
const AudioUnitParameterID frequencyAddress = 0;
参数构造函数的一些参数来自......
我已将地址定义为全局常量:
AUValue
AUValue frequency = 1;
的本地变量:
AUValue
请记住,此时我只关注在整个互联网上使用Audio Unit V3的三个示例项目。我发现很难将整个AU参数舞蹈如何只能通过阅读文档来拼凑起来。
现在谈到使用与AUParameter
" param1"相关联的AUValue
时,(我假设它是如何工作的?)..
然后我在我的音频单元渲染块中捕获了这个AUParameter
(我不清楚它与实际- (AUInternalRenderBlock)internalRenderBlock {
AUValue * param1Capture = &frequency;
return ^AUAudioUnitStatus(AudioUnitRenderActionFlags *actionFlags, const AudioTimeStamp *timestamp, AVAudioFrameCount frameCount, NSInteger outputBusNumber, AudioBufferList *outputData, const AURenderEvent *realtimeEventListHead, AURenderPullInputBlock pullInputBlock) {
// use parameter value
someValue = *param1Capture;
// more dsp stuff..
如何关联的局部变量)..
AUParameter
这就是出现问题的地方。
我声明了对@interface ViewController (){
AudioEngine *_audioEngine;
AUParameter * _param1;
}
的本地引用:
AUAudioUnit
当我的Audio Engine类实例化我的 [_audioEngine setupAUWithComponentDescription:desc andCompletion:^(AUAudioUnit * unit){
_param1 = [unit.parameterTree valueForKey:@"frequency"];
}];
时,它将它传递给我:
[_param1 setValue: 1000];
现在我说:
AUValue
我渲染块中捕获的package appkwekerij.gsr;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
/**
* Created by ralphneeleman on 10-01-17.
*/
public class LwebActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
DrawerLayout drawerLayout;
ActionBarDrawerToggle drawerToggle;
NavigationView navigation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lweb);
WebView webView = (WebView)findViewById(R.id.webView1);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
webView.loadUrl("http://www.leerlingen.gsr.nl");
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@SuppressWarnings("StatementWithEmptyBody")
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_Home) {
findViewById(R.id.home).setVisibility(View.VISIBLE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Lweb) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.VISIBLE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Roosterw) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.VISIBLE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Poll) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.VISIBLE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Staffportal) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.VISIBLE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Parentportal) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.VISIBLE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Mail) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.VISIBLE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_WRTS) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.VISIBLE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Quizlet) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.VISIBLE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_OV) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.VISIBLE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Twitter) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.VISIBLE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Facebook) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.VISIBLE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Contact) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.VISIBLE);
findViewById(R.id.feedback).setVisibility(View.GONE);
} else if (id == R.id.nav_Feedback) {
findViewById(R.id.home).setVisibility(View.GONE);
findViewById(R.id.lweb).setVisibility(View.GONE);
findViewById(R.id.roosterw).setVisibility(View.GONE);
findViewById(R.id.poll).setVisibility(View.GONE);
findViewById(R.id.staffportal).setVisibility(View.GONE);
findViewById(R.id.parentportal).setVisibility(View.GONE);
findViewById(R.id.mail).setVisibility(View.GONE);
findViewById(R.id.WRTS).setVisibility(View.GONE);
findViewById(R.id.quizlet).setVisibility(View.GONE);
findViewById(R.id.ov).setVisibility(View.GONE);
findViewById(R.id.twitter).setVisibility(View.GONE);
findViewById(R.id.facebook).setVisibility(View.GONE);
findViewById(R.id.contact).setVisibility(View.GONE);
findViewById(R.id.feedback).setVisibility(View.VISIBLE);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
保持不变!
我或者忽略了一个错误,一个没有头脑的类型(我可能已经在我的问题中写了一个类型,所以请记住这一点),或者我从根本上误解了这个机制。
如果我需要为此问题提供更多上下文,我可以轻松地将项目推送到Github。
提前致谢。
答案 0 :(得分:1)
问题结果与Core Audio无关,而且与基本语言级错误无关。
frequency
在文件级范围内声明如下:
AUValue frequency = 1;
@implementation MyAudioUnit
@end
我的理解是frequency
现在绑定到文件范围而不是实例范围。因此,在不同的实例上重复设置它只是覆盖了以前的值。因此,最后一次分配是将要呈现的频率。