Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
afab6000
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
afab6000
编写于
4月 17, 2009
作者:
K
kalli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6823446: Gervill SoftLowFrequencyOscillator fails when freq is set to 0 cent or 8.1758 Hz.
Reviewed-by: amenkov
上级
f1dee8fa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
115 addition
and
1 deletion
+115
-1
src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
...asses/com/sun/media/sound/SoftLowFrequencyOscillator.java
+9
-1
test/javax/sound/midi/Gervill/SoftLowFrequencyOscillator/TestProcessControlLogic.java
...l/SoftLowFrequencyOscillator/TestProcessControlLogic.java
+106
-0
未找到文件。
src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
浏览文件 @
afab6000
...
...
@@ -45,6 +45,13 @@ public class SoftLowFrequencyOscillator implements SoftProcess {
private
double
sin_factor
=
0
;
private
static
double
PI2
=
2.0
*
Math
.
PI
;
public
SoftLowFrequencyOscillator
()
{
// If sin_step is 0 then sin_stepfreq must be -INF
for
(
int
i
=
0
;
i
<
sin_stepfreq
.
length
;
i
++)
{
sin_stepfreq
[
i
]
=
Double
.
NEGATIVE_INFINITY
;
}
}
public
void
reset
()
{
for
(
int
i
=
0
;
i
<
used_count
;
i
++)
{
out
[
i
][
0
]
=
0
;
...
...
@@ -53,7 +60,8 @@ public class SoftLowFrequencyOscillator implements SoftProcess {
freq
[
i
][
0
]
=
0
;
delay_counter
[
i
]
=
0
;
sin_phase
[
i
]
=
0
;
sin_stepfreq
[
i
]
=
0
;
// If sin_step is 0 then sin_stepfreq must be -INF
sin_stepfreq
[
i
]
=
Double
.
NEGATIVE_INFINITY
;
sin_step
[
i
]
=
0
;
}
used_count
=
0
;
...
...
test/javax/sound/midi/Gervill/SoftLowFrequencyOscillator/TestProcessControlLogic.java
0 → 100644
浏览文件 @
afab6000
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@summary Test SoftLowFrequencyOscillator processControlLogic method */
import
com.sun.media.sound.AudioSynthesizerPropertyInfo
;
import
com.sun.media.sound.SoftLowFrequencyOscillator
;
import
com.sun.media.sound.SoftSynthesizer
;
public
class
TestProcessControlLogic
{
private
static
float
control_rate
=
147
f
;
private
static
SoftSynthesizer
synth
=
new
SoftSynthesizer
();
private
static
SoftLowFrequencyOscillator
lfo
=
new
SoftLowFrequencyOscillator
();
private
static
void
testLFO
(
boolean
shared
,
int
instance
,
float
freq
,
float
delay
,
float
delay2
)
throws
Exception
{
SoftLowFrequencyOscillator
lfo
=
shared
?
TestProcessControlLogic
.
lfo
:
new
SoftLowFrequencyOscillator
();
lfo
.
reset
();
double
[]
lfo_freq
=
lfo
.
get
(
instance
,
"freq"
);
double
[]
lfo_delay
=
lfo
.
get
(
instance
,
"delay"
);
double
[]
lfo_delay2
=
lfo
.
get
(
instance
,
"delay2"
);
double
[]
lfo_output
=
lfo
.
get
(
instance
,
null
);
lfo_freq
[
0
]
=
freq
;
lfo_delay
[
0
]
=
delay
;
lfo_delay2
[
0
]
=
delay2
;
lfo
.
init
(
synth
);
// For delayCount amount time, the output LFO should be 0.5
int
delayCount
=
(
int
)
((
Math
.
pow
(
2
,
delay
/
1200.0
)
*
control_rate
));
delayCount
+=
(
int
)
((
delay2
*
control_rate
)
/
1000.0
);
for
(
int
i
=
0
;
i
<
delayCount
;
i
++)
{
if
(
Math
.
abs
(
0.5
-
lfo_output
[
0
])
>
0.000001
)
throw
new
Exception
(
"Incorrect LFO output ("
+
"0.5 != "
+
lfo_output
[
0
]+
")!"
);
lfo
.
processControlLogic
();
}
// After the delay the LFO should start oscillate
// Let make sure output is accurate enough
double
p_step
=
(
440.0
/
control_rate
)
*
Math
.
exp
((
freq
-
6900.0
)
*
(
Math
.
log
(
2
)
/
1200.0
));
double
p
=
0
;
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
p
+=
p_step
;
double
predicted_output
=
0.5
+
Math
.
sin
(
p
*
2
*
Math
.
PI
)
*
0.5
;
if
(
Math
.
abs
(
predicted_output
-
lfo_output
[
0
])
>
0.001
)
throw
new
Exception
(
"Incorrect LFO output ("
+
predicted_output
+
" != "
+
lfo_output
[
0
]+
")!"
);
lfo
.
processControlLogic
();
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Get default control rate from synthesizer
AudioSynthesizerPropertyInfo
[]
p
=
synth
.
getPropertyInfo
(
null
);
for
(
int
i
=
0
;
i
<
p
.
length
;
i
++)
{
if
(
p
[
i
].
name
.
equals
(
"control rate"
))
{
control_rate
=
((
Float
)
p
[
i
].
value
).
floatValue
();
break
;
}
}
// Test LFO under various configurations
for
(
int
instance
=
0
;
instance
<
3
;
instance
++)
for
(
int
d1
=
-
3000
;
d1
<
0
;
d1
+=
1000
)
for
(
int
d2
=
0
;
d2
<
5000
;
d2
+=
1000
)
for
(
int
fr
=
-
1000
;
fr
<
1000
;
fr
+=
100
)
{
testLFO
(
true
,
instance
,
(
fr
==
-
1000
)
?
Float
.
NEGATIVE_INFINITY
:
fr
,
(
d1
==
-
3000
)
?
Float
.
NEGATIVE_INFINITY
:
d1
,
d2
);
testLFO
(
false
,
instance
,
(
fr
==
-
1000
)
?
Float
.
NEGATIVE_INFINITY
:
fr
,
(
d1
==
-
3000
)
?
Float
.
NEGATIVE_INFINITY
:
d1
,
d2
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录