{- |
This module allows to cancel events according to some criteria.
In all cases other than 'setInput' and 'setOutput'
the criteria are combined by logical AND.
For every criterion we provide three kinds of accessors:
* @set@: enable a criterion
* @put@: enable or disable a criterion
* @get@: query, whether the criterion is enabled or disabled.
Currently only the @set@ functions are really usable.
The @put@ and @get@ functions would become useful
for manipulating the remove criterion record, that ALSA maintains.
-}moduleSound.ALSA.Sequencer.Event.RemoveMonad(T,run,-- no need to export this, since Event.Remove is not exported as well-- apply,setInput,putInput,getInput,setOutput,putOutput,getOutput,setChannel,putChannel,getChannel,setEventType,putEventType,setTag,putTag,getTag,setDest,putDest,getDest,setTime,putTime,getTime,setIgnoreOff,putIgnoreOff,getIgnoreOff,)whereimportqualifiedSound.ALSA.Sequencer.Event.RemoveasRemoveimportqualifiedSound.ALSA.Sequencer.Marshal.SequencerasSeqimportqualifiedSound.ALSA.Sequencer.Marshal.AddressasAddrimportqualifiedSound.ALSA.Sequencer.Marshal.QueueasQueueimportqualifiedSound.ALSA.Sequencer.Marshal.EventasEventimportqualifiedSound.ALSA.Sequencer.Marshal.TimeasTimeimportqualifiedControl.Monad.Trans.ReaderasMRimportqualifiedControl.Monad.Trans.StateasMSimportqualifiedControl.Monad.Trans.ClassasMTimportControl.Applicative(Applicative,)importqualifiedData.EnumSetasEnumSetimportData.EnumSet((.-.),(.|.),)importControl.Monad(liftM2,)importData.Monoid(mempty,mappend,)newtypeTa=Cons(MR.ReaderTRemove.T(MS.StateTRemove.ConditionIO)a)deriving(Functor,Applicative,Monad)unpack::Ta->Remove.T->Remove.Condition->IO(a,Remove.Condition)unpack(Consm)r=MS.runStateT(MR.runReaderTmr)-- | apply the changes in the Remove monad to the Remove record_apply::Ta->Remove.T->IOa_applymr=doc0<-Remove.getConditionr(a,c1)<-unpackmrc0Remove.setConditionrc1returna-- | Remove events according to the given conditionsrun::Seq.Tmode->Ta->IOarunhm=dor<-Remove.malloc(a,c)<-unpackmrEnumSet.emptyRemove.setConditionrcRemove.runhrreturnaliftGet::(Remove.T->IOa)->TaliftGetf=Cons$MR.ReaderT$MT.lift.fliftGetCond::(Remove.T->IOa)->Remove.Condition->T(Maybea)liftGetCondfcond=dob<-getCondcondifbthenfmapJust$liftGetfelsereturnNothingliftSet::(Remove.T->b->IOa)->b->TaliftSetfx=Cons$MR.ReaderT$MT.lift.flipfxliftSetCond::(Remove.T->a->IOb)->Remove.Condition->a->TbliftSetCondfcondx=domodifyCond$mappendcondliftSetfxliftPutCond::(Remove.T->a->IO())->Remove.Condition->Maybea->T()liftPutCondfcondmx=casemxofNothing->modifyCond$(.-.cond)Justx->liftSetCondfcondxgetCond::Remove.Condition->TBoolgetCondcond=Cons$MT.lift$MS.gets$EnumSet.subsetcondsetCond::Remove.Condition->T()setCondcond=modifyCond$mappendcondputCond::Remove.Condition->Bool->T()putCondcondb=modifyCond$(ifbthen(.|.)elseflip(.-.))condmodifyCond::(Remove.Condition->Remove.Condition)->T()modifyCondf=Cons$MT.lift$MS.modifyf{- |
All events in the local input buffer are removed.
The conditions are not checked for these events.
This is equivalent to 'Event.dropInputBuffer'.
-}setInput::T()putInput::Bool->T()getInput::TBool{- |
Matching events in the local output buffer are removed, too.
Matching events in the kernel buffer are removed in any case.
If there are no further conditions,
then this is equivalent to 'Event.dropOutputBuffer'.
-}setOutput::T()putOutput::Bool->T()getOutput::TBoolsetChannel::Event.Channel->T()putChannel::MaybeEvent.Channel->T()getChannel::T(MaybeEvent.Channel)_setEventType::Event.EType->T()_getEventType::TEvent.ETypesetEventType::Event.Typee=>e->T()putEventType::Event.Typee=>Maybee->T()setTag::Event.Tag->T()putTag::MaybeEvent.Tag->T()getTag::T(MaybeEvent.Tag){- |
ALSA maintainers say, that destination address and queue are checked together,
at least in the kernel buffer.
However up to ALSA-1.0.22 the check for the queue is missing in libasound
for the local buffer.
-}setDest::(Addr.T,Queue.T)->T()putDest::Maybe(Addr.T,Queue.T)->T()getDest::T(Maybe(Addr.T,Queue.T)){- |
NoteOff events are kept in any case.
-}setIgnoreOff::T()putIgnoreOff::Bool->T()getIgnoreOff::TBoolgetInput=getCondRemove.condInputsetInput=setCondRemove.condInputputInput=putCondRemove.condInputgetOutput=getCondRemove.condOutputsetOutput=setCondRemove.condOutputputOutput=putCondRemove.condOutputgetChannel=liftGetCondRemove.getChannelRemove.condDestChannelsetChannel=liftSetCondRemove.setChannelRemove.condDestChannelputChannel=liftPutCondRemove.setChannelRemove.condDestChannel_getEventType=liftGetRemove.getEventType_setEventType=liftSetCondRemove.setEventTypeRemove.condEventTypesetEventType=liftSetCondRemove.setEventTypeRemove.condEventType.Event.expEvputEventType=liftPutCondRemove.setEventTypeRemove.condEventType.fmapEvent.expEvgetTag=liftGetCondRemove.getTagRemove.condTagMatchsetTag=liftSetCondRemove.setTagRemove.condTagMatchputTag=liftPutCondRemove.setTagRemove.condTagMatchgetDestQueue::Remove.T->IO(Addr.T,Queue.T)getDestQueuer=liftM2(,)(Remove.getDestr)(Remove.getQueuer)setDestQueue::Remove.T->(Addr.T,Queue.T)->IO()setDestQueuer(a,q)=Remove.setDestra>>Remove.setQueuerqgetDest=liftGetCondgetDestQueueRemove.condDestsetDest=liftSetCondsetDestQueueRemove.condDestputDest=liftPutCondsetDestQueueRemove.condDestgetIgnoreOff=getCondRemove.condIgnoreOffsetIgnoreOff=setCondRemove.condIgnoreOffputIgnoreOff=putCondRemove.condIgnoreOffgetTime::T(MaybeOrdering,Time.Stamp)getTime=doticks<-getCondRemove.condTimeTickstamp<-ifticksthenfmapTime.Tick$liftGetRemove.getTickTimeelsefmapTime.Real$liftGetRemove.getRealTimeafter<-getCondRemove.condTimeAfterbefore<-getCondRemove.condTimeBeforeletmo=case(after,before)of(False,False)->Nothing(True,False)->JustGT(False,True)->JustLT(True,True)->JustEQreturn(mo,stamp)setTime::Ordering->Time.Stamp->T()setTimeo=putTime$JustoputTime::MaybeOrdering->Time.Stamp->T()putTimemot=domodifyCond(.-.(Remove.condTimeAfter.|.Remove.condTimeBefore))modifyCond$mappend$casemoofNothing->memptyJustLT->Remove.condTimeBeforeJustGT->Remove.condTimeAfterJustEQ->mappendRemove.condTimeBeforeRemove.condTimeAftercasetofTime.Tickx->domodifyCond$(.-.Remove.condTimeTick)liftSetRemove.setTickTimexTime.Realx->domodifyCond$(.|.Remove.condTimeTick)liftSetRemove.setRealTimex