장황한 소리가 들리려고 https://code.google.com/p/android-midi-lib/을 다운로드했습니다. 기본 그랜드 피아노 이외의 MIDI 채널을 사용하는 방법을 알고 싶습니다. 채널이 답이되어야합니다. 그것들을 바꾸는 것은 효과가없는 것처럼 보입니다. 안드로이드에서 16 개의 모든 채널이 그랜드 피아노처럼 들리십니까? 또는 나는 무엇인가 놓치고있다?!?android-midi-lib 채널을 활성화하십시오.
참조 된 프로젝트에서 예제 파일 쓰기 루틴을 적용했습니다. 5 개의 MIDI 채널을 시도했습니다. 그들은 모두 0 번 채널처럼 들립니다. 나는 Droid 2와 S3에 대해 일관된 결과를 보았습니다.
MidiTrack tempoTrack = new MidiTrack();
MidiTrack noteTrack = new MidiTrack();
// 2. Add events to the tracks
// 2a. Track 0 is typically the tempo map
TimeSignature ts = new TimeSignature();
ts.setTimeSignature(4, 4, TimeSignature.DEFAULT_METER, TimeSignature.DEFAULT_DIVISION);
Tempo t = new Tempo();
t.setBpm(bpm);
tempoTrack.insertEvent(ts);
tempoTrack.insertEvent(t);
for(int i = 21; i < 108; i += 5)
{
int channel = 8, pitch = 1 + i, velocity = 100;
noteTrack.insertNote(channel, pitch + 2, velocity, noteTrack.getLengthInTicks(), 120);
}
// 3. Create a MidiFile with the tracks we created
ArrayList<MidiTrack> tracks = new ArrayList<MidiTrack>();
tracks.add(tempoTrack);
tracks.add(noteTrack);
MidiFile midi = new MidiFile(MidiFile.DEFAULT_RESOLUTION, tracks);
// 4. Write the MIDI data to a file
//omitted for clarity
try {
FileInputStream is = new FileInputStream(output);
mediaPlayer.reset();
mediaPlayer.setDataSource(is.getFD()); //there are issues if you pass in the file name
mediaPlayer.prepare();
} catch (Exception e) {
System.err.println(e);
}
나는 내 MIDI 파일 형식에 별다른 영향을 미치지 않습니다. 그러나 채널이 나중에 MediaPlayer에 의해 읽혀지는 파일에 쓰여지는 것으로 생각됩니다. 파일에 쓸 때 채널 정보가 올바른지 확인했습니다. MediaPlayer와 시스템 MIDI 엔진의 용의자가 두 명 있습니다.
@Override
public void writeToFile(OutputStream out, boolean writeType) throws IOException
{
super.writeToFile(out, writeType);
if(writeType)
{
int typeChannel = (mType << 4) + mChannel;
out.write(typeChannel);
}
out.write(mValue1);
if(mType != PROGRAM_CHANGE && mType != CHANNEL_AFTERTOUCH)
{
out.write(mValue2);
}
}
어떤 생각 : 여기
은 MIDI 파일에 채널 정보 (ChannelEvent 클래스)를 작성해야하는 코드의 ... 어디에 초점을 모르겠어요?
완벽하게 작동합니다. 저의 잘못 이해해 주셔서 감사합니다. – stephen