我有cheerapp.wav或cheerapp.mp3其他一些格式.
InputStream in = context.getResources().openRawResource(R.raw.cheerapp);
BufferedInputStream bis = new BufferedInputStream(in, 8000);
// Create a DataInputStream to read the audio data from the saved file
DataInputStream dis = new DataInputStream(bis);
byte[] music = null;
music = new byte[??];
int i = 0; // Read the file into the "music" array
while (dis.available() > 0) {
// dis.read(music[i]); // This assignment does not reverse the order
music[i]=dis.readByte();
i++;
}
dis.close();
Run Code Online (Sandbox Code Playgroud)
对于music从中获取数据的字节数组DataInputStream.我不知道分配的长度是多少.
这是资源而不是文件的原始文件,因此我不知道那个东西的大小.
我在资源文件夹中有两个PCM声音文件.我使用inputstream并将它们转换为bytearray.
然后我通过规范化处理它们并添加music1和music2并输出到字节数组输出.最后,输出数组并将其提供给AudioTrack.
显然,我没有听到任何声音,也没有出现问题.
private void mixSound() throws IOException {
InputStream in1=getResources().openRawResource(R.raw.cheerapp2);
InputStream in2=getResources().openRawResource(R.raw.buzzer2);
byte[] music1 = null;
music1= new byte[in1.available()];
music1=convertStreamToByteArray(in1);
in1.close();
byte[] music2 = null;
music2= new byte[in2.available()];
music2=convertStreamToByteArray(in2);
in2.close();
byte[] output = new byte[music1.length];
audioTrack.play();
for(int i=0; i < output.length; i++){
float samplef1 = music1[i] / 128.0f; // 2^7=128
float samplef2 = music2[i] / 128.0f;
float mixed = samplef1 + samplef2;
// reduce the volume a bit:
mixed *= 0.8;
// hard clipping
if (mixed > 1.0f) mixed …Run Code Online (Sandbox Code Playgroud) 我尝试了2种方法连续解雇2个视图控制器,但只有一个被解雇而不是第二个
方法1
-(void) LoginDone:(NSNotification *)notif
{
[self dismissViewControllerAnimated:YES completion:NULL]; //previous viewcontroller
[self dismissViewControllerAnimated:YES completion:NULL]; //current viewcontroller
}
Run Code Online (Sandbox Code Playgroud)
方法2
-(void) LoginDone:(NSNotification *)notif
{
[self dismissViewControllerAnimated:YES completion:NULL];
[[NSNotificationCenter defaultCenter] postNotificationName:@"LoginDone2" object:nil];
}
-(void) LoginDone2:(NSNotification *)notif
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)
我需要找到一种方法来连续解除之前的viewcontroller和当前的viewcontroller.
最初,我有一个默认的初始化函数
-(id) init
{
if (self=[super init])
{
......
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
但是,我喜欢覆盖init函数以传入自定义对象或其他对象
-(id) initWithScore:(NSString*) score
{
if (self=[super init])
Run Code Online (Sandbox Code Playgroud)
现在有一个错误,说[super init]函数只能用 - (id)init函数调用.
那么我该怎么做才能解决它所以我可以传入对象并使用self = [super init]?
错误:无法在init系列中的方法之外分配给self.
我有以下Html代码
<div id="team">
<h1>Team</h1>
<img src="assets/divider.png" id="divider">
<img src="assets/team.png" id="team_pic">
</div>
Run Code Online (Sandbox Code Playgroud)
以下CSS
div#team {
margin: 0 auto;
margin-left:auto;
margin-right:auto;
right:auto;
left:auto;
}
Run Code Online (Sandbox Code Playgroud)
但是,子元素分隔符和团队图片一直向左.我虽然保证金:汽车将中心的一切.
然后我将以下内容放入子元素中.
div#team img#team_pic {
width:704px;
height:462px;
margin-left:auto;
margin-left:auto;
}
Run Code Online (Sandbox Code Playgroud)
没有,没有任何事情发生,元素仍然留下而不是居中.
$query="INSERT INTO `main_table` (`count`) VALUES ('$count') WHERE userid='$someid'";
Run Code Online (Sandbox Code Playgroud)
基本上我喜欢在main_table中将count的新值插入到变量count中,其中userid等于变量someid.
SQL抱怨此语句的语法.
我下载了一个使用的示例项目,MFMailComposeViewController需求是框架MessageUI,并设置了MFMailComposeViewControllerDelegate.
但是当通过代码时
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
Run Code Online (Sandbox Code Playgroud)
在mailController没有得到一个有效的地址0x0,这意味着它不分配内存.我不知道它不能分配.我查看了示例代码并正确分配了它.
有什么不同?为什么不能分配?