Skip to content

Commit

Permalink
Update: change analyze method
Browse files Browse the repository at this point in the history
  • Loading branch information
chihiro hashimoto committed Oct 4, 2018
1 parent 84cfb31 commit 5793c91
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ class AnalyzeActivity : Activity() {
val data = this@AnalyzeActivity.service?.getTestFreq()

val calculator: SimplePointCalculator = SimplePointCalculator()
calculator.setV1()
val point = calculator.calc(data!!, sampleData)
val sexBaseScore= point.score
val sexBaseSuccess= point.success()

calculator.setCalibrationType(SimplePointCalculator.Companion.CALIBRATION_TYPE.FREQ)
calculator.setNoiseReducer(SimplePointCalculator.Companion.NOISE_RECUDER.V2)
calculator.setV2()
val freqPoint = calculator.calc(data!!, sampleData)
buffer.append(fileName + ", " + id + ", " + sex + ", " + sexBaseScore + ", " + sexBaseSuccess + ", " + freqPoint.score + "\n")

Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/com/chrhsmt/sisheng/debug/CompareActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,22 @@ class CompareActivity : AppCompatActivity() {
val path= SDCardManager().copyAudioFile(file, this@CompareActivity)
this@CompareActivity.service!!.debugTestPlay(file.name, path, callback = object : Runnable {
override fun run() {
val point = this@CompareActivity.service?.analyze()
val v2Point = this@CompareActivity.service?.analyze()

val calcurator = SimplePointCalculator()
calcurator.setCalibrationType(SimplePointCalculator.Companion.CALIBRATION_TYPE.FREQ)
calcurator.setNoiseReducer(SimplePointCalculator.Companion.NOISE_RECUDER.V2)
val v2Point = (this@CompareActivity.service as AudioService)?.analyze(calcurator)
calcurator.setV1()
val v1Point = (this@CompareActivity.service as AudioService)?.analyze(calcurator)

this@CompareActivity.runOnUiThread {
(this@CompareActivity.service as? AudioService)?.addOtherChart(
point?.analyzedFreqList,
v1Point?.analyzedFreqList,
"男女設定キャリブレーション",
Color.rgb(10, 255, 10))
(this@CompareActivity.service as? AudioService)?.addOtherChart(
v2Point?.analyzedFreqList,
"周波数キャリブレーション",
Color.rgb(255, 10, 255))
txtScore.text = String.format("Point: %s, F-Point: %s", point?.score, v2Point?.score)
txtScore.text = String.format("Point: %s, F-Point: %s", v1Point?.score, v2Point?.score)
}
}
})
Expand Down Expand Up @@ -147,22 +147,22 @@ class CompareActivity : AppCompatActivity() {
this@CompareActivity.service!!.clearFrequencies()
this@CompareActivity.service!!.debugTestPlay(file.name, path, playback = true, callback = object : Runnable {
override fun run() {
val point = this@CompareActivity.service?.analyze()
val v2Point = this@CompareActivity.service?.analyze()

val calcurator = SimplePointCalculator()
calcurator.setCalibrationType(SimplePointCalculator.Companion.CALIBRATION_TYPE.FREQ)
calcurator.setNoiseReducer(SimplePointCalculator.Companion.NOISE_RECUDER.V2)
val v2Point = (this@CompareActivity.service as AudioService)?.analyze(calcurator)
calcurator.setV1()
val v1Point = (this@CompareActivity.service as AudioService)?.analyze(calcurator)

this@CompareActivity.runOnUiThread {
(this@CompareActivity.service as? AudioService)?.addOtherChart(
point?.analyzedFreqList,
v1Point?.analyzedFreqList,
"男女設定キャリブレーション",
Color.rgb(10, 255, 10))
(this@CompareActivity.service as? AudioService)?.addOtherChart(
v2Point?.analyzedFreqList,
"周波数キャリブレーション",
Color.rgb(255, 10, 255))
txtScore.text = String.format("Point: %s, F-Point: %s", point?.score, v2Point?.score)
txtScore.text = String.format("Point: %s, F-Point: %s", v1Point?.score, v2Point?.score)

this@CompareActivity.nowStatus = REIBUN_STATUS.NORMAL
this@CompareActivity.updateButtonStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ open class SimplePointCalculator : PointCalculator() {
}
}

var calirationType: CALIBRATION_TYPE = CALIBRATION_TYPE.SEX
var noizeReducer: NOISE_RECUDER = NOISE_RECUDER.V1
var calirationType: CALIBRATION_TYPE = CALIBRATION_TYPE.FREQ
var noizeReducer: NOISE_RECUDER = NOISE_RECUDER.V2

fun setCalibrationType(type: CALIBRATION_TYPE) {
this.calirationType = type
Expand All @@ -34,6 +34,16 @@ open class SimplePointCalculator : PointCalculator() {
this.noizeReducer = type
}

fun setV1() {
this.calirationType = CALIBRATION_TYPE.SEX
this.noizeReducer = NOISE_RECUDER.V1
}

fun setV2() {
this.calirationType = CALIBRATION_TYPE.FREQ
this.noizeReducer = NOISE_RECUDER.V2
}

override fun calc(frequencies: MutableList<Float>, testFrequencies: MutableList<Float>): Point {

var analyzedFreqList: MutableList<Float> = this.copy(frequencies)
Expand Down

0 comments on commit 5793c91

Please sign in to comment.