On Thursday 11 December 2003 11:16 pm, John Check wrote:
> On Thursday 11 December 2003 11:08 pm, John Check wrote:
> > On Thursday 11 December 2003 01:49 pm, Robert Jonsson wrote:
> > > Hi,
> > >
> > > I just tried installing a newer version of alsa. Was running 0.9.8 from
> > > rpm, now I'm running 1.0rc2 from source.
> > > Playback is working again! Whether it is a freak accident or a working
> > > remedy I can't tell. It's evidence anyway.
> > > If you have the same problem, do try it.
> >
> > Doesn't work for me. I tried 1.0rc.2 drivers and libs on a 2.4 kernel and
> > 6.3pre against ALSA 1.0rc2 on a 2.6 kernel, which affect fix the
> > problem.
>
> s/affect fix/doesn't affect/.
>
> > midithread.cpp is about 100 lines longer than in 6.1. I have the code in
> > a IDE now, so I'll start there.
> >
Looks like I'm zeroing in. I put the one from 6.1 tarball into the CVS tree
and it builds and works.
Playback is fine, it records fine, everything A-OK.
I'm not exactly sure what the problem is yet but heres a diff against CVS.
diff -u -r1.5 midithread.cpp
--- midithread.cpp 30 Nov 2003 21:36:38 -0000 1.5
+++ midithread.cpp 12 Dec 2003 04:08:45 -0000
@@ -1,7 +1,7 @@
//=========================================================
// MusE
// Linux Music Editor
-// $Id: midithread.cpp,v 1.5 2003/11/30 21:36:38 wschweer Exp $
+// $Id: midithread.cpp,v 1.57 2003/04/30 13:25:09 muse Exp $
//
// (C) Copyright 2002 Werner Schweer (ws@...)
//=========================================================
@@ -64,7 +64,7 @@
// SEventList
//---------------------------------------------------------
-class SEventList : public std::list<SEvent, RTalloc<SEvent> > {
+class SEventList : public std::list<SEvent> {
public:
SEventList() {}
};
@@ -86,8 +86,6 @@
return map[ev->channel()] < map[e.ev->channel()];
}
-static SEventList sevents;
-
//---------------------------------------------------------
// recTimeStamp
//---------------------------------------------------------
@@ -185,8 +183,7 @@
void MidiThread::recordStop()
{
TrackList* tl = song->tracks();
- int firstTick = startRecord.posTick();
- int lastTick = endRecord.posTick();
+ int lastTick = endRecord.posTick();
bool updateMixer = false;
for (iTrack it = tl->begin(); it != tl->end(); ++it) {
@@ -213,27 +210,13 @@
for (iEvent i = el->begin(); i != el->end(); ++i) {
MidiEvent* ev = (MidiEvent*)i->second;
if (ev->isNote()) {
- if (ev->velo() == 0) {
- // this is a note off event without a note on
- // set note on to begin of recording:
- // velocity info is lost (set to default 80)
-
- ev->setPosTick(firstTick);
- ev->setVelo(80);
- int len = i->first - firstTick;
- if (len <= 0)
- len = 1;
- ev->setLenTick(i->first - firstTick);
- continue;
- }
-
iEvent k = i;
for (++k; k != el->end(); ++k) {
if (ev->isNoteOff((MidiEvent*)k->second)) {
int t = k->first - i->first;
if (t == 0) {
t = 1;
- printf("note len == 0! (set to 1)
\n");
+ printf("len == 0!\n");
}
ev->setLenTick(t);
ev->setVeloOff(((MidiEvent*)i->second)->veloOff());
@@ -242,10 +225,7 @@
}
}
if (k == el->end()) {
- // note off event is missing; set note end
- // to end of recording
-
- int len = lastTick - i->first;
+ int len = lastTick - k->first;
if (len < 1)
len = 1;
ev->setLenTick(len);
@@ -257,7 +237,7 @@
// assign events to parts
//-------------------------------------------------------------
- song->cmdAddRecordedEvents(mt, el, firstTick);
+ song->cmdAddRecordedEvents(mt, el, startRecord.posTick());
el->clear();
}
if (audioOutput.recordFlag()) {
@@ -409,17 +389,11 @@
doSetuid();
timerFd = ::open("/dev/rtc", O_RDWR);
- if (timerFd == -1) {
+ if (timerFd == -1)
perror("cannot open rtc clock /dev/rtc");
- if (!debugMode)
- exit(-1);
- }
if (setRtcTicks()) {
- if (ioctl(timerFd, RTC_PIE_ON, 0) == -1) {
+ if (ioctl(timerFd, RTC_PIE_ON, 0) == -1)
perror("MidiThread: start: RTC_PIE_ON failed");
- if (!debugMode)
- exit(-1);
- }
}
undoSetuid();
Thread::start();
@@ -445,7 +419,6 @@
void MidiThread::threadStop()
{
if (timerFd != -1) {
- ioctl(timerFd, RTC_PIE_OFF, 0);
::close(timerFd);
timerFd = -1;
}
@@ -465,11 +438,8 @@
if (timerFd != -1) {
addPollFd(timerFd, POLLIN, midiTick, this, 0);
}
- else {
- fprintf(stderr, "updatePollFd: no timer fd\n");
- if (!debugMode)
- exit(-1);
- }
+ else
+ printf("updatePollFd: no timer fd\n");
addPollFd(toThreadFdr, POLLIN, ::readMsg, this, 0);
@@ -522,10 +492,6 @@
bool MidiThread::setRtcTicks()
{
if (timerFd == -1) {
- if (!debugMode) {
- fprintf(stderr, "setRtcTicks: not rtc timer avail.");
- exit(-1);
- }
setPollWait(10); // 10 msec
realRtcTicks = 100;
return false;
@@ -536,8 +502,6 @@
strerror(errno));
fprintf(stderr, "precise timer not available\n");
close(timerFd);
- if (!debugMode)
- exit(-1);
timerFd = -1;
setPollWait(10); // 10 msec
realRtcTicks = 100;
@@ -601,7 +565,8 @@
case SEQM_PLAY:
if (state == IDLE && msg->a)
startPlay(song->cpos());
- else if ((state == PLAY || state == PRECOUNT) && !msg->a)
+ else if ((state == PLAY || state == PRECOUNT)
+ && !msg->a)
stopPlay();
break;
case MIDI_ADD_SYNTHI:
@@ -749,6 +714,7 @@
void MidiThread::initDevices()
{
+// printf("init Devices\n");
//
// mark all used devices in song as active
//
@@ -758,34 +724,12 @@
TrackList* tracks = song->tracks();
for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
- Track* t = *it;
- if (t->type() != Track::MIDI && t->type() != Track::DRUM)
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
+ if (track == 0)
continue;
- MidiTrack* track = (MidiTrack*)t;
activeDevices[track->outPort()] = true;
}
-
- //
- // test for explicit instrument initialization
- //
-
- for (int i = 0; i < MIDI_PORTS; ++i) {
- if (!activeDevices[i])
- continue;
- MidiPort* port = &midiPorts[i];
- MidiInstrument* instr = port->instrument();
- if (instr) {
- EventList* events = instr->midiInit();
- if (events->empty())
- continue;
- MPEventList el;
- for (iEvent ie = events->begin(); ie != events->end(); +
+ie)
- el.add(0, (MidiEvent*)(ie->second), i, 0);
- el.play();
- activeDevices[i] = false; // no standard initialization
- }
- }
//
// damit Midi-Devices, die mehrere Ports besitzen, wie z.B.
// das Korg NS5R, nicht mehrmals zwischen GM und XG/GS hin und
@@ -793,7 +737,7 @@
// initialisiert, und dann erst XG/GS
//
for (int i = 0; i < MIDI_PORTS; ++i) {
- if (!activeDevices[i])
+ if (activeDevices[i] == false)
continue;
MidiPort* port = &midiPorts[i];
switch(song->mtype()) {
@@ -803,12 +747,12 @@
case MT_GM:
case MT_XG:
port->gmOn();
- // usleep(200000); // wait 200ms
+ usleep(200000); // wait 200ms
break;
}
}
for (int i = 0; i < MIDI_PORTS; ++i) {
- if (!activeDevices[i])
+ if (activeDevices[i] == false)
continue;
MidiPort* port = &midiPorts[i];
switch(song->mtype()) {
@@ -818,17 +762,17 @@
break;
case MT_GS:
port->gsOn();
- // usleep(50000); // wait 50 ms
+ usleep(50000); // wait 50 ms
break;
case MT_XG:
port->xgOn();
- // usleep(50000); // wait 50 ms
+ usleep(50000); // wait 50 ms
break;
}
}
for (int i = 0; i < MIDI_PORTS; ++i) {
- if (!activeDevices[i])
+ if (activeDevices[i] == false)
continue;
MidiPort* port = &midiPorts[i];
//
@@ -999,8 +943,8 @@
if (ev->type() == MidiEvent::Meta)
continue;
if (track->type() == Track::DRUM) {
- int instr = ev->pitch();
- if (ev->isNote() && drumMap[instr].mute) //
Ignore muted drums
+ int instr = drumOutmap[ev->pitch()];
+ if (ev->isNote() && drumMap[instr].mute)
continue;
}
int tick = ev->posTick() + delay +
part->posTick();
@@ -1012,17 +956,9 @@
{
int len = ev->lenTick();
int pitch = ev->pitch();
- if (track->type() == Track::DRUM) { //
Map drum-notes to the drum-map values
- int instr = ev->pitch();
- pitch = drumMap[instr].anote;
- port = drumMap[instr].port;
- channel = drumMap[instr].channel;
- }
- else
- pitch+= (track->transposition +
song->globalPitchShift()); //Transpose non-drum notes
-
-
int velo = ev->velo();
+ int gpitch = track->type() ==
Track::DRUM ? 0 : song->globalPitchShift();
+ pitch += track->transposition +
gpitch;
if (pitch > 127)
pitch = 127;
if (pitch < 0)
@@ -1059,8 +995,8 @@
default:
playEvents.add(tick, ev, port, channel);
break;
- } //end switch
- }//end for
+ }
+ }
}
}
}
@@ -1213,27 +1149,17 @@
beatClickNote, 0);
}
}
- //
- // play all event upto/including _midiTick
- //
- sevents.clear();
-
- // collect stuck notes
+ SEventList sevents;
MPEventRange range1 = stuckNotes.equal_range(_midiTick);
for (iMPEvent k = stuckNotes.begin(); k != range1.second; ++k)
sevents.push_back(SEvent(&k->second));
-
- // collect play notes
MPEventRange range2 = playEvents.equal_range(_midiTick);
for (iMPEvent k = playEvents.begin(); k != range2.second; ++k)
sevents.push_back(SEvent(&k->second));
-
if (!sevents.empty()) {
sevents.sort();
for (iSEvent sk = sevents.begin(); sk != sevents.end(); ++sk)
playEvent(sk->ev);
- //
- // why recompute range1?
MPEventRange range1 = stuckNotes.equal_range(_midiTick);
stuckNotes.erase(stuckNotes.begin(), range1.second);
playEvents.erase(playEvents.begin(), range2.second);
|