Tag: fadeout

Android:文字淡入淡出

我已经阅读了这个stackoverflow问题和答案,并尝试实现淡入淡出的文本: 如何让Android中的文字淡入淡出? 这是我的实现: public class ShowActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show); final TextView mSwitcher = (TextView) findViewById(R.id.textFade); mSwitcher.setText(“old text”); final Animation in = new AlphaAnimation(0.0f, 1.0f); in.setDuration(5000); final Animation out = new AlphaAnimation(1.0f, 0.0f); out.setDuration(5000); out.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mSwitcher.setText(“New Text”); mSwitcher.startAnimation(in); } @Override […]

如何控制MIDI通道的音量

我有这个代码: Synthesizer synthesizer = MidiSystem.getSynthesizer(); synthesizer.open(); Instrument[] instrument = synthesizer.getDefaultSoundbank().getInstruments(); synthesizer.loadInstrument(instrument[29]); MidiChannel[] channels = synthesizer.getChannels(); MidiChannel channel = channels[1]; channel.programChange(29); channel.noteOn(noteNumber, 127); Teszthang.sleep(2000); channel.noteOff(noteNumber); 所以这是一个例子,以最大音量(127)播放声音2秒。 但是我想控制通道的音量,比如在2秒后,音量会在另外2秒内淡出。 我怎么能这样做? 我知道这些方法: channel.controlChange(controller, value); channel.setPolyPressure(noteNumber, pressure); 但这些不会改变任何音量! 我不知道如何使用这些方法。 如何在noteOn()播放后更改频道的音量?