[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDI (was Re: [Denemo-devel] Anacrusis script needed)

From: Jeremiah Benham
Subject: Re: MIDI (was Re: [Denemo-devel] Anacrusis script needed)
Date: Thu, 10 Sep 2009 16:02:25 -0500

On Thu, 2009-09-10 at 21:00 +0100, Richard Shann wrote:
> On Thu, 2009-09-10 at 14:06 -0500, Jeremiah Benham wrote:
> > On Thu, 2009-09-10 at 17:15 +0100, Richard Shann wrote:
> > > On Thu, 2009-09-10 at 08:08 -0500, Jeremiah Benham wrote:
> > > > On Wed, 2009-09-09 at 22:09 +0100, Richard Shann wrote:
> > > > 
> > > > > I don't have any understanding of this stuff at the moment, so I
> > > > can't
> > > > > help without reading up on it. Usually there is an example that
> > > > comes
> > > > > with these libraries that you can modify and integrate - is that
> > > > where
> > > > > you started? Or did you work from the docs? 
> > > > 
> > > > I started with the docs and then went to the manual. After studying a
> > > > few examples I feel like I am getting to grips with it. I just pushed
> > > > some code to git that emulates a "monosynth" (a synth incapable of
> > > > polyphony). It is not a synth though because it just writes midi data
> > > > to
> > > > the jack port. It sends an all note off
> > > Is sending all note off just something to workaround some bug? You would
> > > presumably just want to send a noteon and then a noteoff after the right
> > > amount of time?
> > > What happens when you try to do this?
> > 
> > If I do just noteon then noteoff a user would to hit "c" then "d" they
> > would hear c and d at the same time until there corresponding noteoffs
> > were reached. I did not want that.
> I can imagine two sorts of audio feedback people might want when
> entering notes at the keyboard
>      1. a short pitch is emitted corresponding to the note at the cursor
>         when the keystroke has been acted on. So c followed by sharp
>         would result in two short notes. If the player put in notes
>         quickly enough they might overlap a bit.
>      2. a pitch sounded for the prevailing duration, but this would only
>         really be useful when inputting folk type melodies not involving
>         adding an accidental. (Otherwise two notes would sound, and the
>         merit of the system - being able to play music in in time -
>         would be lost).
> However if the user were to define commands that combined inserting a
> note with adding an accidental, this might change:
>       c  -> the note c
>       Shift-c  -> the note c-sharp
>       Alt-c -> the note c-flat
> If someone were to define such an entry method, they would include their
> desired audio output in the script for each command, I guess.

This sounds a bit complicated and tedious just for immediate playback. 

> There is a built-in "playback notes entered immediately code"; this code
> I think should just result in short notes as in (1) above as this would
> generally be the most useful thing.
> >  Currently if not compiled with jack
> > and the user enters a note via script like this:
> > 
> > (d-C)
> > (d-Sharpen)
> > 
> > They do not here "c" and "cis" at the same time. The only here "cis".
> I can confirm that this happens. 

Yes. I actually thought this was a feature not a bug. I like it this
way. Oh well.

> I can't imagine why! Very strange. Even
> if you do d-RefreshDisplay you only get the one note. 

If you want to hear both pitches you can do this:

(sleep 1)

You can sleep less than that actually. I don't remember what the scheme
procedure is at the moment but I think the smallest was .5 seconds to
hear both pitches if IIRC.

> And
> (d-C)
> (d-RefreshDisplay)
>  (d-Sharpen)
>  (d-CursorUp)
>  (d-AddNoteToChord)
> issues only one note.
> This is all accidental. I think scripts should take control of the audio
> output if they want it. (Not sure how you would stop the effect we are
> seeing - perhaps it is only one note per script?)

No. Just putting a type of wait or sleep of sorts in there. 

> > This is the behavior I am trying to emulate with this particular jack
> > callback function. Do you have another recommendation? 
> "jack callback function"?
> Not too clear what you meant: is it clear that I think that all you need
> to do is wire in a short note output at the same time and in the same
> way as the current output via portaudio?

I don't know anything about portaudio. I would have to read the docs and
study that code also. They way all the jack midi examples I have seen
work like this (If I finally understand correctly). There is a callback
thread that runs a callback every $SAMPLERATE/$FRAMES_SIZE. A frame size
of 1024 would process 1024 samples each time the callback is called. I
learned that the callback itself can be used as a timer for events
because of this. I tried writing to the buffer outside this callback
thread and for some reason it sounded awful. I heard more than one
NOTE_ON even though I know it was only called once. So what I am doing
is creating a global buffer to hold the information that the callback
needs to process. At the moment the global buffer only holds one note at
time. I will need to change this if I want to do more complicated
things. I have to have something that remembers to turn off previously
sounded notes when it is there time. Perhaps I will create a structure
and hold the structure in a stack in a GList and then free the list
member after NOTE_OFF has sent. If not a GList maybe a smf from libsmf.
Its still kind of fuzzy in my head how to do this. At least I learned
how to use jack as a timer. 


> So entering a triad you would hear the notes as you typed them in/added
> them to the chord.
> Richard
> > One drawback to
> > this is that if user enters a triad only the lowest note is heard. I was
> > trying to recreate consistency amongst the types of midi/audio out. I
> > can modify this function to check if more than one note exists do all
> > note off followed by a triad of noteons then a triad of noteoffs. I say
> > triad but it can be any arbitrary number of notes. 
> > 
> > Jeremiah
> > 
> > > Richard
> > > 
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > Denemo-devel mailing list
> > > address@hidden
> > >
> > 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]