diff --git a/app/src/main/cpp/Envelope.h b/app/src/main/cpp/Envelope.h index 396a00f..134dcc5 100644 --- a/app/src/main/cpp/Envelope.h +++ b/app/src/main/cpp/Envelope.h @@ -18,7 +18,7 @@ float attackIncrement, delayIncrement, releaseIncrement; float value = 1; public: - float attack = 0.05, delay = 0.2, sustain = 0.75, release = 0.05; + float attack = 0.05, delay = 0.2, sustain = 0.75, release = 1; void initialize(AudioHost *host); void startNote(); diff --git a/app/src/main/cpp/Envelope.h b/app/src/main/cpp/Envelope.h index 396a00f..134dcc5 100644 --- a/app/src/main/cpp/Envelope.h +++ b/app/src/main/cpp/Envelope.h @@ -18,7 +18,7 @@ float attackIncrement, delayIncrement, releaseIncrement; float value = 1; public: - float attack = 0.05, delay = 0.2, sustain = 0.75, release = 0.05; + float attack = 0.05, delay = 0.2, sustain = 0.75, release = 1; void initialize(AudioHost *host); void startNote(); diff --git a/app/src/main/java/com/lukas/music/instruments/Rhythm.kt b/app/src/main/java/com/lukas/music/instruments/Rhythm.kt index 074d518..c449d04 100644 --- a/app/src/main/java/com/lukas/music/instruments/Rhythm.kt +++ b/app/src/main/java/com/lukas/music/instruments/Rhythm.kt @@ -5,11 +5,19 @@ import kotlin.concurrent.schedule object Rhythm { - var on = false + var on: Boolean = false + set(on) { + field = on + for (instrument in Instrument.instruments) { + instrument.stop() + } + } + fun start() { Timer().schedule(0, 500) { - on = !on - Song.currentSong.step() + if (on) { + Song.currentSong.step() + } } } } \ No newline at end of file diff --git a/app/src/main/cpp/Envelope.h b/app/src/main/cpp/Envelope.h index 396a00f..134dcc5 100644 --- a/app/src/main/cpp/Envelope.h +++ b/app/src/main/cpp/Envelope.h @@ -18,7 +18,7 @@ float attackIncrement, delayIncrement, releaseIncrement; float value = 1; public: - float attack = 0.05, delay = 0.2, sustain = 0.75, release = 0.05; + float attack = 0.05, delay = 0.2, sustain = 0.75, release = 1; void initialize(AudioHost *host); void startNote(); diff --git a/app/src/main/java/com/lukas/music/instruments/Rhythm.kt b/app/src/main/java/com/lukas/music/instruments/Rhythm.kt index 074d518..c449d04 100644 --- a/app/src/main/java/com/lukas/music/instruments/Rhythm.kt +++ b/app/src/main/java/com/lukas/music/instruments/Rhythm.kt @@ -5,11 +5,19 @@ import kotlin.concurrent.schedule object Rhythm { - var on = false + var on: Boolean = false + set(on) { + field = on + for (instrument in Instrument.instruments) { + instrument.stop() + } + } + fun start() { Timer().schedule(0, 500) { - on = !on - Song.currentSong.step() + if (on) { + Song.currentSong.step() + } } } } \ No newline at end of file diff --git a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt index 23517ea..22c87fe 100644 --- a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt +++ b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt @@ -1,13 +1,12 @@ package com.lukas.music.ui.fragments import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.lukas.music.MainActivity -import com.lukas.music.R +import androidx.fragment.app.Fragment import com.lukas.music.databinding.FragmentPlayBinding +import com.lukas.music.instruments.Rhythm class PlayFragment : Fragment() { lateinit var binding: FragmentPlayBinding @@ -18,6 +17,7 @@ ): View? { binding = FragmentPlayBinding.inflate(inflater) binding.playSwitch.setOnCheckedChangeListener { _, isOn -> + Rhythm.on = isOn } return binding.root }