@@ -0,0 +1,6 @@ | |||
*~ | |||
*.bak | |||
*.swp | |||
*.[ao] | |||
TAGS | |||
.nfs* |
@@ -0,0 +1,340 @@ | |||
GNU GENERAL PUBLIC LICENSE | |||
Version 2, June 1991 | |||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. | |||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
Everyone is permitted to copy and distribute verbatim copies | |||
of this license document, but changing it is not allowed. | |||
Preamble | |||
The licenses for most software are designed to take away your | |||
freedom to share and change it. By contrast, the GNU General Public | |||
License is intended to guarantee your freedom to share and change free | |||
software--to make sure the software is free for all its users. This | |||
General Public License applies to most of the Free Software | |||
Foundation's software and to any other program whose authors commit to | |||
using it. (Some other Free Software Foundation software is covered by | |||
the GNU Library General Public License instead.) You can apply it to | |||
your programs, too. | |||
When we speak of free software, we are referring to freedom, not | |||
price. Our General Public Licenses are designed to make sure that you | |||
have the freedom to distribute copies of free software (and charge for | |||
this service if you wish), that you receive source code or can get it | |||
if you want it, that you can change the software or use pieces of it | |||
in new free programs; and that you know you can do these things. | |||
To protect your rights, we need to make restrictions that forbid | |||
anyone to deny you these rights or to ask you to surrender the rights. | |||
These restrictions translate to certain responsibilities for you if you | |||
distribute copies of the software, or if you modify it. | |||
For example, if you distribute copies of such a program, whether | |||
gratis or for a fee, you must give the recipients all the rights that | |||
you have. You must make sure that they, too, receive or can get the | |||
source code. And you must show them these terms so they know their | |||
rights. | |||
We protect your rights with two steps: (1) copyright the software, and | |||
(2) offer you this license which gives you legal permission to copy, | |||
distribute and/or modify the software. | |||
Also, for each author's protection and ours, we want to make certain | |||
that everyone understands that there is no warranty for this free | |||
software. If the software is modified by someone else and passed on, we | |||
want its recipients to know that what they have is not the original, so | |||
that any problems introduced by others will not reflect on the original | |||
authors' reputations. | |||
Finally, any free program is threatened constantly by software | |||
patents. We wish to avoid the danger that redistributors of a free | |||
program will individually obtain patent licenses, in effect making the | |||
program proprietary. To prevent this, we have made it clear that any | |||
patent must be licensed for everyone's free use or not licensed at all. | |||
The precise terms and conditions for copying, distribution and | |||
modification follow. | |||
GNU GENERAL PUBLIC LICENSE | |||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |||
0. This License applies to any program or other work which contains | |||
a notice placed by the copyright holder saying it may be distributed | |||
under the terms of this General Public License. The "Program", below, | |||
refers to any such program or work, and a "work based on the Program" | |||
means either the Program or any derivative work under copyright law: | |||
that is to say, a work containing the Program or a portion of it, | |||
either verbatim or with modifications and/or translated into another | |||
language. (Hereinafter, translation is included without limitation in | |||
the term "modification".) Each licensee is addressed as "you". | |||
Activities other than copying, distribution and modification are not | |||
covered by this License; they are outside its scope. The act of | |||
running the Program is not restricted, and the output from the Program | |||
is covered only if its contents constitute a work based on the | |||
Program (independent of having been made by running the Program). | |||
Whether that is true depends on what the Program does. | |||
1. You may copy and distribute verbatim copies of the Program's | |||
source code as you receive it, in any medium, provided that you | |||
conspicuously and appropriately publish on each copy an appropriate | |||
copyright notice and disclaimer of warranty; keep intact all the | |||
notices that refer to this License and to the absence of any warranty; | |||
and give any other recipients of the Program a copy of this License | |||
along with the Program. | |||
You may charge a fee for the physical act of transferring a copy, and | |||
you may at your option offer warranty protection in exchange for a fee. | |||
2. You may modify your copy or copies of the Program or any portion | |||
of it, thus forming a work based on the Program, and copy and | |||
distribute such modifications or work under the terms of Section 1 | |||
above, provided that you also meet all of these conditions: | |||
a) You must cause the modified files to carry prominent notices | |||
stating that you changed the files and the date of any change. | |||
b) You must cause any work that you distribute or publish, that in | |||
whole or in part contains or is derived from the Program or any | |||
part thereof, to be licensed as a whole at no charge to all third | |||
parties under the terms of this License. | |||
c) If the modified program normally reads commands interactively | |||
when run, you must cause it, when started running for such | |||
interactive use in the most ordinary way, to print or display an | |||
announcement including an appropriate copyright notice and a | |||
notice that there is no warranty (or else, saying that you provide | |||
a warranty) and that users may redistribute the program under | |||
these conditions, and telling the user how to view a copy of this | |||
License. (Exception: if the Program itself is interactive but | |||
does not normally print such an announcement, your work based on | |||
the Program is not required to print an announcement.) | |||
These requirements apply to the modified work as a whole. If | |||
identifiable sections of that work are not derived from the Program, | |||
and can be reasonably considered independent and separate works in | |||
themselves, then this License, and its terms, do not apply to those | |||
sections when you distribute them as separate works. But when you | |||
distribute the same sections as part of a whole which is a work based | |||
on the Program, the distribution of the whole must be on the terms of | |||
this License, whose permissions for other licensees extend to the | |||
entire whole, and thus to each and every part regardless of who wrote it. | |||
Thus, it is not the intent of this section to claim rights or contest | |||
your rights to work written entirely by you; rather, the intent is to | |||
exercise the right to control the distribution of derivative or | |||
collective works based on the Program. | |||
In addition, mere aggregation of another work not based on the Program | |||
with the Program (or with a work based on the Program) on a volume of | |||
a storage or distribution medium does not bring the other work under | |||
the scope of this License. | |||
3. You may copy and distribute the Program (or a work based on it, | |||
under Section 2) in object code or executable form under the terms of | |||
Sections 1 and 2 above provided that you also do one of the following: | |||
a) Accompany it with the complete corresponding machine-readable | |||
source code, which must be distributed under the terms of Sections | |||
1 and 2 above on a medium customarily used for software interchange; or, | |||
b) Accompany it with a written offer, valid for at least three | |||
years, to give any third party, for a charge no more than your | |||
cost of physically performing source distribution, a complete | |||
machine-readable copy of the corresponding source code, to be | |||
distributed under the terms of Sections 1 and 2 above on a medium | |||
customarily used for software interchange; or, | |||
c) Accompany it with the information you received as to the offer | |||
to distribute corresponding source code. (This alternative is | |||
allowed only for noncommercial distribution and only if you | |||
received the program in object code or executable form with such | |||
an offer, in accord with Subsection b above.) | |||
The source code for a work means the preferred form of the work for | |||
making modifications to it. For an executable work, complete source | |||
code means all the source code for all modules it contains, plus any | |||
associated interface definition files, plus the scripts used to | |||
control compilation and installation of the executable. However, as a | |||
special exception, the source code distributed need not include | |||
anything that is normally distributed (in either source or binary | |||
form) with the major components (compiler, kernel, and so on) of the | |||
operating system on which the executable runs, unless that component | |||
itself accompanies the executable. | |||
If distribution of executable or object code is made by offering | |||
access to copy from a designated place, then offering equivalent | |||
access to copy the source code from the same place counts as | |||
distribution of the source code, even though third parties are not | |||
compelled to copy the source along with the object code. | |||
4. You may not copy, modify, sublicense, or distribute the Program | |||
except as expressly provided under this License. Any attempt | |||
otherwise to copy, modify, sublicense or distribute the Program is | |||
void, and will automatically terminate your rights under this License. | |||
However, parties who have received copies, or rights, from you under | |||
this License will not have their licenses terminated so long as such | |||
parties remain in full compliance. | |||
5. You are not required to accept this License, since you have not | |||
signed it. However, nothing else grants you permission to modify or | |||
distribute the Program or its derivative works. These actions are | |||
prohibited by law if you do not accept this License. Therefore, by | |||
modifying or distributing the Program (or any work based on the | |||
Program), you indicate your acceptance of this License to do so, and | |||
all its terms and conditions for copying, distributing or modifying | |||
the Program or works based on it. | |||
6. Each time you redistribute the Program (or any work based on the | |||
Program), the recipient automatically receives a license from the | |||
original licensor to copy, distribute or modify the Program subject to | |||
these terms and conditions. You may not impose any further | |||
restrictions on the recipients' exercise of the rights granted herein. | |||
You are not responsible for enforcing compliance by third parties to | |||
this License. | |||
7. If, as a consequence of a court judgment or allegation of patent | |||
infringement or for any other reason (not limited to patent issues), | |||
conditions are imposed on you (whether by court order, agreement or | |||
otherwise) that contradict the conditions of this License, they do not | |||
excuse you from the conditions of this License. If you cannot | |||
distribute so as to satisfy simultaneously your obligations under this | |||
License and any other pertinent obligations, then as a consequence you | |||
may not distribute the Program at all. For example, if a patent | |||
license would not permit royalty-free redistribution of the Program by | |||
all those who receive copies directly or indirectly through you, then | |||
the only way you could satisfy both it and this License would be to | |||
refrain entirely from distribution of the Program. | |||
If any portion of this section is held invalid or unenforceable under | |||
any particular circumstance, the balance of the section is intended to | |||
apply and the section as a whole is intended to apply in other | |||
circumstances. | |||
It is not the purpose of this section to induce you to infringe any | |||
patents or other property right claims or to contest validity of any | |||
such claims; this section has the sole purpose of protecting the | |||
integrity of the free software distribution system, which is | |||
implemented by public license practices. Many people have made | |||
generous contributions to the wide range of software distributed | |||
through that system in reliance on consistent application of that | |||
system; it is up to the author/donor to decide if he or she is willing | |||
to distribute software through any other system and a licensee cannot | |||
impose that choice. | |||
This section is intended to make thoroughly clear what is believed to | |||
be a consequence of the rest of this License. | |||
8. If the distribution and/or use of the Program is restricted in | |||
certain countries either by patents or by copyrighted interfaces, the | |||
original copyright holder who places the Program under this License | |||
may add an explicit geographical distribution limitation excluding | |||
those countries, so that distribution is permitted only in or among | |||
countries not thus excluded. In such case, this License incorporates | |||
the limitation as if written in the body of this License. | |||
9. The Free Software Foundation may publish revised and/or new versions | |||
of the General Public License from time to time. Such new versions will | |||
be similar in spirit to the present version, but may differ in detail to | |||
address new problems or concerns. | |||
Each version is given a distinguishing version number. If the Program | |||
specifies a version number of this License which applies to it and "any | |||
later version", you have the option of following the terms and conditions | |||
either of that version or of any later version published by the Free | |||
Software Foundation. If the Program does not specify a version number of | |||
this License, you may choose any version ever published by the Free Software | |||
Foundation. | |||
10. If you wish to incorporate parts of the Program into other free | |||
programs whose distribution conditions are different, write to the author | |||
to ask for permission. For software which is copyrighted by the Free | |||
Software Foundation, write to the Free Software Foundation; we sometimes | |||
make exceptions for this. Our decision will be guided by the two goals | |||
of preserving the free status of all derivatives of our free software and | |||
of promoting the sharing and reuse of software generally. | |||
NO WARRANTY | |||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |||
REPAIR OR CORRECTION. | |||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | |||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | |||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | |||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |||
POSSIBILITY OF SUCH DAMAGES. | |||
END OF TERMS AND CONDITIONS | |||
How to Apply These Terms to Your New Programs | |||
If you develop a new program, and you want it to be of the greatest | |||
possible use to the public, the best way to achieve this is to make it | |||
free software which everyone can redistribute and change under these terms. | |||
To do so, attach the following notices to the program. It is safest | |||
to attach them to the start of each source file to most effectively | |||
convey the exclusion of warranty; and each file should have at least | |||
the "copyright" line and a pointer to where the full notice is found. | |||
<one line to give the program's name and a brief idea of what it does.> | |||
Copyright (C) <year> <name of author> | |||
This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with this program; if not, write to the Free Software | |||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
Also add information on how to contact you by electronic and paper mail. | |||
If the program is interactive, make it output a short notice like this | |||
when it starts in an interactive mode: | |||
Gnomovision version 69, Copyright (C) year name of author | |||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |||
This is free software, and you are welcome to redistribute it | |||
under certain conditions; type `show c' for details. | |||
The hypothetical commands `show w' and `show c' should show the appropriate | |||
parts of the General Public License. Of course, the commands you use may | |||
be called something other than `show w' and `show c'; they could even be | |||
mouse-clicks or menu items--whatever suits your program. | |||
You should also get your employer (if you work as a programmer) or your | |||
school, if any, to sign a "copyright disclaimer" for the program, if | |||
necessary. Here is a sample; alter the names: | |||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program | |||
`Gnomovision' (which makes passes at compilers) written by James Hacker. | |||
<signature of Ty Coon>, 1 April 1989 | |||
Ty Coon, President of Vice | |||
This General Public License does not permit incorporating your program into | |||
proprietary programs. If your program is a subroutine library, you may | |||
consider it more useful to permit linking proprietary applications with the | |||
library. If this is what you want to do, use the GNU Library General | |||
Public License instead of this License. |
@@ -0,0 +1,95 @@ | |||
# Makefile for the Non Sequencer. | |||
# Copyright 2007-2008 Jonathan Moore Liles | |||
# This file is licencesd under version 2 of the GPL. | |||
# config | |||
PREFIX=/usr/local/ | |||
SYSTEM_PATH=$(PREFIX)/share/non-sequencer/ | |||
DOCUMENT_PATH=$(PREFIX)/share/doc/non-sequencer/ | |||
USE_LASH=1 | |||
# Debugging | |||
CFLAGS:=-O0 -ggdb -fno-omit-frame-pointer -Wall | |||
# Production | |||
# CFLAGS:=-O3 -fomit-frame-pointer -DNDEBUG | |||
CFLAGS+=-DINSTALL_PREFIX=\"$(PREFIX)\" \ | |||
-DSYSTEM_PATH=\"$(SYSTEM_PATH)\" \ | |||
-DDOCUMENT_PATH=\"$(DOCUMENT_PATH)\" | |||
CXXFLAGS:=$(CFLAGS) -fno-exceptions -fno-rtti `fltk-config --cxxflags` `pkg-config jack --atleast-version 0.105 || echo -DJACK_MIDI_PROTO_API` `pkg-config jack --cflags` `pkg-config --cflags sigc++-2.0` | |||
LIBS=`pkg-config --libs jack` `fltk-config --use-images --ldflags` `pkg-config --libs sigc++-2.0` | |||
ifeq ($(USE_LASH),1) | |||
LIBS+=-llash | |||
CXXFLAGS+=-DUSE_LASH `pkg-config --cflags lash-1.0` | |||
endif | |||
SRCS= \ | |||
canvas.C \ | |||
debug.C \ | |||
event.C \ | |||
event_list.C \ | |||
grid.C \ | |||
gui/draw.C \ | |||
gui/event_edit.C \ | |||
gui/input.C \ | |||
gui/ui.C \ | |||
gui/widgets.C \ | |||
instrument.C \ | |||
jack.C \ | |||
lash.C \ | |||
main.C \ | |||
mapping.C \ | |||
midievent.C \ | |||
pattern.C \ | |||
phrase.C \ | |||
scale.C \ | |||
sequence.C \ | |||
smf.C \ | |||
transport.C | |||
OBJS=$(SRCS:.C=.o) | |||
.PHONEY: all clean install | |||
all: non makedepend | |||
clean: | |||
rm -f non makedepend $(OBJS) | |||
@ echo Done | |||
.C.o: | |||
@ echo -n "Compiling: "; tput bold; tput setaf 3; echo $<; tput sgr0; true | |||
@ $(CXX) $(CXXFLAGS) -c $< -o $@ | |||
%.C : %.fl | |||
@ cd gui && fluid -c ../$< | |||
non: $(OBJS) | |||
@ echo -n "Linking..." | |||
@ rm -f $@ | |||
@ $(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $@ || (tput bold; tput setaf 1; echo Error!; tput sgr0) | |||
@ test -x $@ && echo done. | |||
install: | |||
@ echo -n "Installing..." | |||
@ install non $(PREFIX)/bin | |||
@ mkdir -p "$(SYSTEM_PATH)" | |||
@ cp -r instruments "$(SYSTEM_PATH)" | |||
@ mkdir -p "$(DOCUMENT_PATH)" | |||
@ cp doc/*.{html,png} "$(DOCUMENT_PATH)" | |||
@ echo done | |||
# make -C doc install | |||
TAGS: $(SRCS) | |||
etags $(SRCS) | |||
makedepend: $(SRCS) | |||
@ echo -n Checking dependencies... | |||
@ makedepend -f- -- $(CXXFLAGS) -- $(SRCS) > makedepend 2>/dev/null && echo done. | |||
include makedepend |
@@ -0,0 +1,43 @@ | |||
! title TODO list for the Non-sequencer | |||
-- | |||
; General | |||
* per phrase tempo setting? Perhaps a percentage of global tempo? | |||
* add channel field to event list widget (but channel bits in pattern | |||
event lists are currently meaningless.) | |||
* add uneditable "other" tab to event list widget. | |||
* new Phrase playback mode. In this mode, a single phrase is looped, | |||
and the next phrase to be looped can be queued. This is similar the | |||
the playlist, but not linear from bar 1. | |||
* live performance record. Does this have to be internal to Non? Is | |||
there no jack MIDI capable recorder that could be connected to all | |||
non ports? How would ports be handled anyway? As separate tracks in | |||
an SMF-1 file, perhaps? | |||
* add global setting for composer name/copyright to be included in | |||
song files. | |||
* !!! now that we're not using stupid-ass STL list container for the | |||
event lists we can perhaps keep a pointer to the next event in the | |||
playback thread, which would eliminate much overhead. This might | |||
also require keeping a "dirtied" bit in the grid to let the | |||
playback thread know that the UI thread has changed the list | |||
between process calls (also, what about transport relocations?) | |||
* guess key signature of imports? | |||
* figure out how to handle SysEx events with Jack MIDI (packetize them?) | |||
* add chords to scale list... a pattern using the scale of a chord | |||
would contain a melody within that chord. | |||
; Canvas | |||
* custom scrollbar widget (dots) | |||
* add vertical scrollbar widget to canvas. | |||
* update beat/measure line drawing when BPB changes. | |||
* update phrase height when number of patterns changes... (good use | |||
for a signal?) | |||
* phrases need a way to show/hide relevant patterns. The whole | |||
"mapping" system is a total mess. How about only showing rows | |||
containing events? How would one add a pattern in this system? A | |||
button that adds an event for the given pattern? | |||
* split canvas into separate widgets (ruler, names, canvas)? |
@@ -0,0 +1,876 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2007-2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
/* This is a generic double-buffering, optimizing canvas interface to | |||
grids (patterns and phrases). It draws only what is necessary to keep | |||
the display up-to-date. Actual drawing functions are in draw.C */ | |||
#include "canvas.H" | |||
#include "pattern.H" | |||
#include "gui/draw.H" | |||
#include "common.h" | |||
#include "non.H" | |||
cell_t ** | |||
Canvas::_alloc_array ( void ) | |||
{ | |||
cell_t **a; | |||
int one = sizeof( typeof( a ) ) * m.vp->w; | |||
int two = sizeof( typeof( a[0] ) ) * (m.vp->h * m.vp->w); | |||
a = (cell_t **) malloc( one + two ); | |||
m.size = one + two; | |||
cell_t *c = (cell_t *) (((unsigned char *)a) + one); | |||
for ( uint x = m.vp->w; x-- ; ) | |||
{ | |||
a[x] = c; | |||
c += m.vp->h; | |||
for ( uint y = m.vp->h; y-- ; ) | |||
{ | |||
a[ x ][ y ].flags = 0; | |||
a[ x ][ y ].state = -1; | |||
a[ x ][ y ].shape = SQUARE; | |||
a[ x ][ y ].color = 0; | |||
} | |||
} | |||
m.w = m.vp->w; | |||
m.h = m.vp->h; | |||
return a; | |||
} | |||
Canvas::Canvas ( ) | |||
{ | |||
m.height = m.width = m.div_w = m.div_h = m.playhead = m.margin_top = m.margin_left = m.playhead = m.w = m.h = m.p1 = m.p2 = 0; | |||
m.margin_top = ruler_height; | |||
m.ruler_drawn = false; | |||
m.mapping_drawn = false; | |||
m.grid_drawn = false; | |||
m.current = m.previous = NULL; | |||
m.row_compact = true; | |||
m.maxh = 128; | |||
m.vp = NULL; | |||
} | |||
void | |||
Canvas::handle_event_change ( void ) | |||
{ | |||
/* mark the song as dirty and pass the signal on */ | |||
song.dirty = true; | |||
signal_draw(); | |||
} | |||
/** change grid to /g/, returns TRUE if new grid size differs from old */ | |||
bool | |||
Canvas::grid ( Grid *g ) | |||
{ | |||
bool r = false; | |||
if ( m.grid ) | |||
{ | |||
} | |||
m.grid = g; | |||
if ( ! g ) | |||
return false; | |||
if ( m.vp ) | |||
if ( m.vp->w != g->viewport.w || | |||
m.vp->h != g->viewport.h ) | |||
r = true; | |||
m.vp = &g->viewport; | |||
char *s = m.vp->dump(); | |||
DEBUG( "viewport: %s", s ); | |||
free( s ); | |||
m.mapping_drawn = m.ruler_drawn = false; | |||
resize_grid(); | |||
_update_row_mapping(); | |||
m.shape = m.grid->draw_shape(); | |||
/* connect signals */ | |||
/* FIXME: what happens when we do this twice? */ | |||
g->signal_events_change.connect( mem_fun( this, &Canvas::handle_event_change ) ); | |||
g->signal_settings_change.connect( signal_settings_change.make_slot() ); | |||
signal_draw(); | |||
signal_settings_change(); | |||
return r; | |||
} | |||
/** keep row compaction tables up-to-date */ | |||
void | |||
Canvas::_update_row_mapping ( void ) | |||
{ | |||
/* reset */ | |||
for ( int i = 128; i-- ; ) | |||
m.rtn[i] = m.ntr[i] = -1; | |||
DEBUG( "updating row mapping" ); | |||
/* rebuild */ | |||
int r = 0; | |||
for ( int n = 0; n < 128; ++n ) | |||
{ | |||
if ( m.grid->row_name( n ) ) | |||
{ | |||
m.rtn[r] = n; | |||
m.ntr[n] = r; | |||
++r; | |||
} | |||
} | |||
if ( m.row_compact && r ) | |||
m.maxh = r; | |||
else | |||
m.maxh = 128; | |||
m.vp->h = min( m.vp->h, m.maxh ); | |||
} | |||
/** change grid mapping */ | |||
void | |||
Canvas::changed_mapping ( void ) | |||
{ | |||
_update_row_mapping(); | |||
m.mapping_drawn = false; | |||
m.vp->y = (m.maxh / 2) - (m.vp->h / 2); | |||
resize(); | |||
int old_margin = m.margin_left; | |||
m.margin_left = 0; | |||
m.draw = false; | |||
m.grid->draw_row_names( this ); | |||
if ( m.margin_left != old_margin ) | |||
signal_resize(); | |||
else | |||
signal_draw(); | |||
} | |||
Grid * | |||
Canvas::grid ( void ) | |||
{ | |||
return m.grid; | |||
} | |||
/** recalculate node sizes based on physical dimensions */ | |||
void | |||
Canvas::resize ( void ) | |||
{ | |||
if ( ! m.vp ) | |||
return; | |||
m.div_w = (m.width - m.margin_left) / m.vp->w; | |||
m.div_h = (m.height - m.margin_top) / m.vp->h; | |||
m.border_w = min( m.div_w, m.div_h ) / 8; | |||
m.mapping_drawn = m.ruler_drawn = false; | |||
} | |||
/** reallocate buffers to match grid dimensions */ | |||
void | |||
Canvas::resize_grid ( void ) | |||
{ | |||
// _update_row_mapping(); | |||
resize(); | |||
if ( m.vp ) | |||
{ | |||
if ( m.vp->w != m.w || m.vp->h != m.h || | |||
m.div_w != m.old_div_w || m.div_h != m.old_div_h ) | |||
{ | |||
if ( m.grid_drawn ) | |||
signal_resize(); | |||
m.old_div_w = m.div_w; | |||
m.old_div_h = m.div_h; | |||
} | |||
else | |||
return; | |||
} | |||
DEBUG( "resizing grid %dx%d", m.vp->w, m.vp->h ); | |||
if ( m.previous ) | |||
{ | |||
free( m.previous ); | |||
free( m.current ); | |||
} | |||
m.current = _alloc_array(); | |||
m.previous = _alloc_array(); | |||
m.grid_drawn = false; | |||
} | |||
/** inform the canvas with new phsyical dimensions */ | |||
void | |||
Canvas::resize ( int x, int y, int w, int h ) | |||
{ | |||
m.origin_x = x; | |||
m.origin_y = y; | |||
m.width = w; | |||
m.height = h; | |||
resize(); | |||
} | |||
/***********/ | |||
/* Drawing */ | |||
/***********/ | |||
/** copy last buffer into current */ | |||
void | |||
Canvas::copy ( void ) | |||
{ | |||
for ( uint y = m.vp->h; y-- ; ) | |||
for ( uint x = m.vp->w; x-- ; ) | |||
m.current[ x ][ y ] = m.previous[ x ][ y ]; | |||
} | |||
/** reset last buffer */ | |||
void | |||
Canvas::_reset ( void ) | |||
{ | |||
cell_t empty; | |||
for ( uint y = m.vp->h; y-- ; ) | |||
for ( uint x = m.vp->w; x-- ; ) | |||
m.current[ x ][ y ] = empty; | |||
} | |||
/** prepare current buffer for drawing (draw "background") */ | |||
void | |||
Canvas::clear ( void ) | |||
{ | |||
uint rule = m.grid->ppqn(); | |||
uint lx = m.grid->ts_to_x( m.grid->length() ); | |||
for ( uint y = m.vp->h; y--; ) | |||
for ( uint x = m.vp->w; x--; ) | |||
{ | |||
m.current[ x ][ y ].color = 0; | |||
m.current[ x ][ y ].shape = m.shape; | |||
m.current[ x ][ y ].state = EMPTY; | |||
m.current[ x ][ y ].flags = 0; | |||
} | |||
for ( int x = m.vp->w - rule; x >= 0; x -= rule ) | |||
for ( uint y = m.vp->h; y-- ; ) | |||
m.current[ x ][ y ].state = LINE; | |||
int sx = (int)(lx - m.vp->x) >= 0 ? lx - m.vp->x : 0; | |||
for ( int x = sx; x < m.vp->w; ++x ) | |||
for ( int y = m.vp->h; y-- ; ) | |||
m.current[ x ][ y ].state = PARTIAL; | |||
} | |||
/** is /x/ within the viewport? */ | |||
bool | |||
Canvas::viewable_x ( int x ) | |||
{ | |||
return x >= m.vp->x && x < m.vp->x + m.vp->w; | |||
} | |||
/** flush delta of last and current buffers to screen, then flip them */ | |||
void | |||
Canvas::flip ( void ) | |||
{ | |||
/* FIXME: should this not go in clear()? */ | |||
if ( m.p1 != m.p2 ) | |||
{ | |||
if ( viewable_x( m.p1 ) ) draw_line( m.p1 - m.vp->x, F_P1 ); | |||
if ( viewable_x( m.p2 ) ) draw_line( m.p2 - m.vp->x, F_P2 ); | |||
} | |||
if ( viewable_x( m.playhead ) ) draw_line( m.playhead - m.vp->x, F_PLAYHEAD ); | |||
for ( uint y = m.vp->h; y--; ) | |||
for ( uint x = m.vp->w; x--; ) | |||
{ | |||
cell_t *c = &m.current[ x ][ y ]; | |||
cell_t *p = &m.previous[ x ][ y ]; | |||
if ( *c != *p ) | |||
gui_draw_shape( m.origin_x + m.margin_left + x * m.div_w, m.origin_y + m.margin_top + y * m.div_h, m.div_w, m.div_h, m.border_w, | |||
c->shape, c->state, c->flags, c->color ); | |||
} | |||
cell_t **tmp = m.previous; | |||
m.previous = m.current; | |||
m.current = tmp; | |||
} | |||
/** redraw the ruler at the top of the canvas */ | |||
void | |||
Canvas::redraw_ruler ( void ) | |||
{ | |||
m.margin_top = gui_draw_ruler( m.origin_x + m.margin_left, m.origin_y, m.vp->w, m.div_w, m.grid->division(), m.vp->x, | |||
m.p1 - m.vp->x, m.p2 - m.vp->x ); | |||
m.ruler_drawn = true; | |||
} | |||
/** callback called by Grid::draw_row_names() to draw an individual row name */ | |||
void | |||
Canvas::draw_row_name ( int y, const char *name, int color ) | |||
{ | |||
bool draw = m.draw; | |||
bool clear = false; | |||
y = ntr( y ); | |||
if ( ! m.row_compact && ! name ) | |||
clear = true; | |||
y -= m.vp->y; | |||
int bx = m.origin_x; | |||
int by = m.origin_y + m.margin_top + y * m.div_h; | |||
int bw = min( m.margin_left, m.width / 8 ); | |||
int bh = m.div_h; | |||
if ( y < 0 || y >= m.vp->h ) | |||
draw = false; | |||
if ( clear && draw ) | |||
gui_clear_area( bx, by, bw, bh ); | |||
else | |||
m.margin_left = max( m.margin_left, gui_draw_string( bx, by, | |||
bw, bh, | |||
color, | |||
name, | |||
draw ) ); | |||
} | |||
/** redraw row names */ | |||
void | |||
Canvas::redraw_mapping ( void ) | |||
{ | |||
m.margin_left = 0; | |||
m.draw = false; | |||
m.grid->draw_row_names( this ); | |||
resize(); | |||
m.draw = true; | |||
m.grid->draw_row_names( this ); | |||
m.mapping_drawn = true; | |||
} | |||
void | |||
Canvas::draw_mapping ( void ) | |||
{ | |||
if ( ! m.mapping_drawn ) redraw_mapping(); | |||
} | |||
void | |||
Canvas::draw_ruler ( void ) | |||
{ | |||
if ( ! m.ruler_drawn ) redraw_ruler(); | |||
} | |||
/** "draw" a shape in the backbuffer */ | |||
void | |||
Canvas::draw_shape ( int x, int y, int shape, int state, int color, bool selected ) | |||
{ | |||
y = ntr( y ); | |||
if ( y < 0 ) | |||
return; | |||
// adjust for viewport. | |||
x -= m.vp->x; | |||
y -= m.vp->y; | |||
if ( x < 0 || y < 0 || x >= m.vp->w || y >= m.vp->h ) | |||
return; | |||
m.current[ x ][ y ].shape = shape; | |||
m.current[ x ][ y ].color = color; | |||
m.current[ x ][ y ].state = (uint)m.vp->x + x > m.grid->ts_to_x( m.grid->length() ) ? PARTIAL : state; | |||
m.current[ x ][ y ].flags = selected ? F_SELECTED : 0; | |||
} | |||
/** callback used by Grid::draw() */ | |||
void | |||
Canvas::draw_dash ( int x, int y, int l, int shape, int color, bool selected ) | |||
{ | |||
draw_shape( x, y, shape, FULL, color, selected ); | |||
for ( int i = x + l - 1; i > x; i-- ) | |||
{ | |||
draw_shape( i, y, shape, CONTINUED, 0, selected ); | |||
} | |||
} | |||
/** draw a vertical line with flags */ | |||
void | |||
Canvas::draw_line ( int x, int flags ) | |||
{ | |||
for ( uint y = m.vp->h; y-- ; ) | |||
m.current[ x ][ y ].flags |= flags; | |||
} | |||
/** draw only the playhead--without reexamining the grid */ | |||
int | |||
Canvas::draw_playhead ( void ) | |||
{ | |||
int x = m.grid->ts_to_x( m.grid->index() ); | |||
if ( m.playhead == x ) | |||
return 0; | |||
m.playhead = x; | |||
if ( m.playhead < m.vp->x || m.playhead >= m.vp->x + m.vp->w ) | |||
{ | |||
if ( config.follow_playhead ) | |||
{ | |||
m.vp->x = m.playhead / m.vp->w * m.vp->w; | |||
m.ruler_drawn = false; | |||
signal_draw(); | |||
return 0; | |||
} | |||
} | |||
copy(); | |||
for ( uint x = m.vp->w; x-- ; ) | |||
for ( uint y = m.vp->h; y-- ; ) | |||
m.current[ x ][ y ].flags &= ~ (F_PLAYHEAD | F_P1 | F_P2 ); | |||
flip(); | |||
return 1; | |||
} | |||
/** draw ONLY those nodes necessary to bring the canvas up-to-date with the grid */ | |||
void | |||
Canvas::draw ( void ) | |||
{ | |||
DEBUG( "drawing canvas" ); | |||
draw_mapping(); | |||
draw_ruler(); | |||
m.grid_drawn = true; | |||
m.grid->draw( this, m.vp->x, m.vp->y, m.vp->w, m.vp->h ); | |||
} | |||
/** redraw every node on the canvas from the buffer (without | |||
* necessarily reexamining the grid) */ | |||
void | |||
Canvas::redraw ( void ) | |||
{ | |||
DEBUG( "redrawing canvas" ); | |||
if ( ! m.grid_drawn ) | |||
draw(); | |||
m.ruler_drawn = false; | |||
m.mapping_drawn = false; | |||
draw_mapping(); | |||
draw_ruler(); | |||
for ( int y = m.vp->h; y--; ) | |||
for ( int x = m.vp->w; x--; ) | |||
{ | |||
cell_t c = m.previous[ x ][ y ]; | |||
if ( c.shape > HEXAGON ) return; | |||
if ( m.vp->x + x == m.playhead ) | |||
c.flags |= F_PLAYHEAD; | |||
gui_draw_shape( m.origin_x + m.margin_left + x * m.div_w, m.origin_y + m.margin_top + y * m.div_h, m.div_w, m.div_h, m.border_w, | |||
c.shape, c.state, c.flags, c.color ); | |||
} | |||
} | |||
/** convert pixel coords into grid coords. returns true if valid */ | |||
bool | |||
Canvas::grid_pos ( int *x, int *y ) | |||
{ | |||
*y = (*y - m.margin_top - m.origin_y) / m.div_h; | |||
*x = (*x - m.margin_left - m.origin_x) / m.div_w; | |||
if ( *x < 0 || *y < 0 || *x >= m.vp->w || *y >= m.vp->h ) | |||
return false; | |||
/* adjust for viewport */ | |||
*x += m.vp->x; | |||
*y += m.vp->y; | |||
/* adjust for row-compaction */ | |||
*y = rtn( *y ); | |||
return true; | |||
} | |||
/******************/ | |||
/* Input handlers */ | |||
/******************/ | |||
/* These methods translate viewport pixel coords to absolute grid | |||
coords and pass on to the grid. */ | |||
void | |||
Canvas::set ( int x, int y ) | |||
{ | |||
if ( y - m.origin_y < m.margin_top ) | |||
/* looks like a click on the ruler */ | |||
{ | |||
if ( x - m.margin_left - m.origin_x >= 0 ) | |||
{ | |||
m.p1 = m.vp->x + ((x - m.margin_left - m.origin_x) / m.div_w); | |||
m.ruler_drawn = false; | |||
} | |||
_lr(); | |||
signal_draw(); | |||
return; | |||
} | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
m.grid->put( x, y, 0 ); | |||
} | |||
void | |||
Canvas::unset ( int x, int y ) | |||
{ | |||
if ( y - m.origin_y < m.margin_top ) | |||
/* looks like a click on the ruler */ | |||
{ | |||
if ( x - m.margin_left - m.origin_x >= 0 ) | |||
{ | |||
m.p2 = m.vp->x + ((x - m.margin_left - m.origin_x) / m.div_w); | |||
m.ruler_drawn = false; | |||
} | |||
_lr(); | |||
signal_draw(); | |||
return; | |||
} | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
m.grid->del( x, y ); | |||
} | |||
void | |||
Canvas::adj_color ( int x, int y, int n ) | |||
{ | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
m.grid->adj_velocity( x, y, n ); | |||
} | |||
void | |||
Canvas::adj_length ( int x, int y, int n ) | |||
{ | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
m.grid->adj_duration( x, y, n ); | |||
} | |||
void | |||
Canvas::select ( int x, int y ) | |||
{ | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
m.grid->select( x, y, true ); | |||
} | |||
void | |||
Canvas::move_selected ( int dir, int n ) | |||
{ | |||
switch ( dir ) | |||
{ | |||
case RIGHT: | |||
m.grid->move_selected( n ); | |||
break; | |||
case LEFT: | |||
m.grid->move_selected( 0 - n ); | |||
break; | |||
case UP: | |||
case DOWN: | |||
{ | |||
/* row-compaction makes this a little complicated */ | |||
event_list *el = m.grid->events(); | |||
/* FIXME: don't allow movement beyond the edges! */ | |||
/* int hi, lo; */ | |||
/* m.grid->selected_hi_lo_note( &hi, &lo ); */ | |||
/* hi = ntr( hi ) > 0 ? ntr( hi ) : */ | |||
/* if ( m.grid->y_to_note( ntr( hi ) ) ) */ | |||
if ( dir == UP ) | |||
for ( int y = 0; y <= m.maxh; ++y ) | |||
el->rewrite_selected( m.grid->y_to_note( rtn( y ) ), m.grid->y_to_note( rtn( y - n ) ) ); | |||
else | |||
for ( int y = m.maxh; y >= 0; --y ) | |||
el->rewrite_selected( m.grid->y_to_note( rtn( y ) ), m.grid->y_to_note( rtn( y + n ) ) ); | |||
m.grid->events( el ); | |||
delete el; | |||
break; | |||
} | |||
} | |||
} | |||
void | |||
Canvas::randomize_row ( int y ) | |||
{ | |||
int x = m.margin_left; | |||
if ( ! grid_pos( &x, &y ) ) | |||
return; | |||
((pattern*)m.grid)->randomize_row( y, song.random.feel, song.random.probability ); | |||
} | |||
void | |||
Canvas::_lr ( void ) | |||
{ | |||
int l, r; | |||
if ( m.p2 > m.p1 ) | |||
{ | |||
l = m.p1; | |||
r = m.p2; | |||
} | |||
else | |||
{ | |||
l = m.p2; | |||
r = m.p1; | |||
} | |||
m.p1 = l; | |||
m.p2 = r; | |||
} | |||
void | |||
Canvas::select_range ( void ) | |||
{ | |||
m.grid->select( m.p1, m.p2 ); | |||
} | |||
void | |||
Canvas::crop ( void ) | |||
{ | |||
m.grid->crop( m.p1, m.p2 ); | |||
m.vp->x = 0; | |||
m.p2 = m.p2 - m.p1; | |||
m.p1 = 0; | |||
m.ruler_drawn = false; | |||
} | |||
void | |||
Canvas::delete_time ( void ) | |||
{ | |||
m.grid->delete_time( m.p1, m.p2 ); | |||
} | |||
void | |||
Canvas::insert_time ( void ) | |||
{ | |||
m.grid->insert_time( m.p1, m.p2 ); | |||
} | |||
/** paste range as new grid */ | |||
void | |||
Canvas::duplicate_range ( void ) | |||
{ | |||
Grid *g = m.grid->clone(); | |||
g->crop( m.p1, m.p2 ); | |||
g->viewport.x = 0; | |||
} | |||
void | |||
Canvas::row_compact ( int n ) | |||
{ | |||
switch ( n ) | |||
{ | |||
case OFF: | |||
m.row_compact = false; | |||
m.maxh = 128; | |||
break; | |||
case ON: | |||
m.row_compact = true; | |||
m.vp->y = 0; | |||
_update_row_mapping(); | |||
break; | |||
case TOGGLE: | |||
row_compact( m.row_compact ? OFF : ON ); | |||
break; | |||
} | |||
_reset(); | |||
m.mapping_drawn = false; | |||
} | |||
void | |||
Canvas::pan ( int dir, int n ) | |||
{ | |||
switch ( dir ) | |||
{ | |||
case LEFT: case RIGHT: case TO_PLAYHEAD: case TO_NEXT_NOTE: case TO_PREV_NOTE: | |||
/* handle horizontal movement specially */ | |||
n *= m.grid->division(); | |||
m.ruler_drawn = false; | |||
break; | |||
default: | |||
n *= 5; | |||
m.mapping_drawn = false; | |||
break; | |||
} | |||
switch ( dir ) | |||
{ | |||
case LEFT: | |||
m.vp->x = max( m.vp->x - n, 0 ); | |||
break; | |||
case RIGHT: | |||
m.vp->x += n; | |||
break; | |||
case TO_PLAYHEAD: | |||
m.vp->x = m.playhead - (m.playhead % m.grid->division()); | |||
break; | |||
case UP: | |||
m.vp->y = max( m.vp->y - n, 0 ); | |||
break; | |||
case DOWN: | |||
m.vp->y = min( m.vp->y + n, m.maxh - m.vp->h ); | |||
break; | |||
case TO_NEXT_NOTE: | |||
{ | |||
int x = m.grid->next_note_x( m.vp->x ); | |||
m.vp->x = x - (x % m.grid->division() ); | |||
break; | |||
} | |||
case TO_PREV_NOTE: | |||
{ | |||
int x = m.grid->prev_note_x( m.vp->x ); | |||
m.vp->x = x - (x % m.grid->division() ); | |||
break; | |||
} | |||
} | |||
signal_draw(); | |||
} | |||
/** adjust horizontal zoom (* n) */ | |||
void | |||
Canvas::h_zoom ( float n ) | |||
{ | |||
m.vp->w = max( 32, min( (int)(m.vp->w * n), 256 ) ); | |||
resize_grid(); | |||
} | |||
/** adjust vertical zoom (* n) */ | |||
void | |||
Canvas::v_zoom ( float n ) | |||
{ | |||
m.vp->h = max( 1, min( (int)(m.vp->h * n), m.maxh ) ); | |||
resize_grid(); | |||
} | |||
void | |||
Canvas::notes ( char *s ) | |||
{ | |||
m.grid->notes( s ); | |||
} | |||
char * | |||
Canvas::notes ( void ) | |||
{ | |||
return m.grid->notes(); | |||
} |
@@ -0,0 +1,175 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2007-2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
#pragma once | |||
#include "grid.H" | |||
#include "gui/draw.H" | |||
#include <sigc++/sigc++.h> | |||
using namespace sigc; | |||
class Mapping; | |||
struct cell_t { | |||
unsigned char color; | |||
unsigned char shape : 4; | |||
unsigned char state : 4; | |||
unsigned char flags : 4; | |||
bool | |||
operator!= ( const cell_t &rhs ) | |||
{ | |||
return color != rhs.color || shape != rhs.shape || state != rhs.state || flags != rhs.flags; | |||
} | |||
}; | |||
enum { LEFT, RIGHT, UP, DOWN, TO_PLAYHEAD, TO_NEXT_NOTE, TO_PREV_NOTE }; | |||
class Canvas : public trackable | |||
{ | |||
struct { | |||
int origin_x, origin_y; | |||
int width, height; | |||
int margin_left, margin_top; | |||
int div_w, div_h; | |||
int border_w; | |||
int old_div_w, old_div_h; | |||
int maxh; | |||
bool ruler_drawn; | |||
bool mapping_drawn; | |||
bool grid_drawn; | |||
int playhead; /* where the playhead is for this canvas. only used for display. */ | |||
/* /\* these are in logical units, not pixels *\/ */ | |||
/* int w, h; /\* viewport *\/ */ | |||
/* int x, y; /\* pan position *\/ */ | |||
enum { PATTERN, SEQUENCE } mode; | |||
Grid *grid; /* grid currently connected to this canvas */ | |||
size_t size; | |||
cell_t **current, **previous; | |||
bool draw; /* really drawing, or just checking size? */ | |||
int rule; | |||
bool row_compact; /* use row-compaction? */ | |||
/* tables used for row-compaction */ | |||
int rtn[128]; /* row-to-note */ | |||
int ntr[128]; /* note-to-row */ | |||
int shape; | |||
Viewport *vp; | |||
int w, h; | |||
uint p1, p2; /* cursors */ | |||
} m; | |||
int rtn ( int r ); | |||
int ntr ( int n ); | |||
void _update_row_mapping ( void ); | |||
cell_t ** _alloc_array ( void ); | |||
void redraw_ruler ( void ); | |||
void redraw_mapping ( void ); | |||
void draw_mapping ( void ); | |||
void draw_ruler ( void ); | |||
void _reset ( void ); | |||
void _lr ( void ); | |||
bool viewable_x ( int x ); | |||
void draw_line ( int x, int flags ); | |||
public: | |||
enum { OFF, ON, TOGGLE }; | |||
signal <void> signal_settings_change; | |||
signal <void> signal_draw; | |||
signal <void> signal_resize; | |||
Canvas ( ); | |||
void handle_event_change ( void ); | |||
void set ( int x, int y ); | |||
bool grid ( Grid *g ); | |||
void changed_mapping ( void ); | |||
Grid * grid ( void ); | |||
void resize ( void ); | |||
void resize_grid ( void ); | |||
void resize ( int x, int y, int w, int h ); | |||
void copy ( void ); | |||
void clear ( void ); | |||
void flip ( void ); | |||
void draw_row_name ( int y, const char *name, int color ); | |||
void draw_shape ( int x, int y, int shape, int state, int color, bool selected ); | |||
void draw_dash ( int x, int y, int l, int shape, int color, bool selected ); | |||
int draw_playhead ( void ); | |||
void draw ( void ); | |||
void redraw ( void ); | |||
bool grid_pos ( int *x, int *y ); | |||
void unset ( int x, int y ); | |||
void adj_color ( int x, int y, int n ); | |||
void adj_length ( int x, int y, int n ); | |||
void select ( int x, int y ); | |||
void select_range ( void ); | |||
void duplicate_range ( void ); | |||
void crop ( void ); | |||
void row_compact ( int n ); | |||
void pan ( int dir, int n ); | |||
void h_zoom ( float n ); | |||
void v_zoom ( float n ); | |||
void notes ( char *s ); | |||
char * notes ( void ); | |||
void randomize_row ( int y ); | |||
void delete_time ( void ); | |||
void insert_time ( void ); | |||
void move_selected ( int dir, int n ); | |||
}; | |||
inline int | |||
Canvas::rtn ( int r ) | |||
{ | |||
return m.row_compact ? m.rtn[ r ] : r; | |||
} | |||
inline int | |||
Canvas::ntr ( int n ) | |||
{ | |||
return m.row_compact ? m.ntr[ n ] : n; | |||
} |
@@ -0,0 +1,38 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2007,2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
// #pragma once | |||
typedef unsigned char byte_t; | |||
typedef unsigned long tick_t; | |||
typedef unsigned int uint; | |||
/* #define min(x,y) ((x) < (y) ? (x) : (y)) */ | |||
/* #define max(x,y) ((x) > (y) ? (x) : (y)) */ | |||
#include <algorithm> | |||
using namespace std; | |||
#define elementsof(x) (sizeof((x)) / sizeof((x)[0])) | |||
#include "config.h" | |||
#include "const.h" | |||
#include "debug.h" |
@@ -0,0 +1,3 @@ | |||
// #define INSTALL_PREFIX "/usr/local/" |
@@ -0,0 +1,45 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2007,2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
#pragma once | |||
/* getting around this will require bank switching etc, and | |||
before that happens I'd like to see a song with 128 phrases in it. */ | |||
const int MAX_PHRASE = 128; | |||
const int MAX_PATTERN = 128; | |||
const unsigned int PPQN = 480; | |||
/* interval between GUI updates for playhead movement, etc. */ | |||
const double TRANSPORT_POLL_INTERVAL = 0.05; | |||
const char APP_NAME[] = "Non"; | |||
const char APP_TITLE[] = "The Non-Sequencer"; | |||
const char COPYRIGHT[] = "Copyright (c) 2007-2008 Jonathan Moore Liles"; | |||
#define PACKAGE "non" | |||
#define VERSION "1.9.0" | |||
/* directories */ | |||
// #define SYSTEM_PATH INSTALL_PREFIX "share/non-sequencer/" | |||
// #define DOCUMENT_PATH INSTALL_PREFIX "share/doc/non-sequencer/" | |||
#define USER_CONFIG_DIR ".non/" | |||
#define INSTRUMENT_DIR "instruments/" |
@@ -0,0 +1,10 @@ | |||
#pragma once | |||
struct dash | |||
{ | |||
tick_t timestamp; | |||
tick_t length; | |||
unsigned char color; | |||
}; | |||
@@ -0,0 +1,60 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
#include "debug.h" | |||
void | |||
warnf ( warning_t level, | |||
const char *module, | |||
const char *file, | |||
const char *function, size_t line, const char *fmt, ... ) | |||
{ | |||
va_list args; | |||
static const char *level_tab[] = { | |||
"message", "\033[1;32m", | |||
"warning", "\033[1;33m", | |||
"assertion", "\033[1;31m" | |||
}; | |||
if ( module ) | |||
fprintf( stderr, "[%s] ", module ); | |||
#ifndef NDEBUG | |||
if ( file ) | |||
fprintf( stderr, "%s", file ); | |||
if ( line ) | |||
fprintf( stderr, ":%i", line ); | |||
if ( function ) | |||
fprintf( stderr, " %s()", function ); | |||
fprintf( stderr, ": " ); | |||
#endif | |||
if ( unsigned( ( level << 1 ) + 1 ) < | |||
( sizeof( level_tab ) / sizeof( level_tab[0] ) ) ) | |||
fprintf( stderr, "%s", level_tab[( level << 1 ) + 1] ); | |||
if ( fmt ) | |||
{ | |||
va_start( args, fmt ); | |||
vfprintf( stderr, fmt, args ); | |||
va_end( args ); | |||
} | |||
fprintf( stderr, "\033[0m\n" ); | |||
} |
@@ -0,0 +1,115 @@ | |||
/*******************************************************************************/ | |||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||
/* */ | |||
/* This program is free software; you can redistribute it and/or modify it */ | |||
/* under the terms of the GNU General Public License as published by the */ | |||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||
/* option) any later version. */ | |||
/* */ | |||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||
/* more details. */ | |||
/* */ | |||
/* You should have received a copy of the GNU General Public License along */ | |||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
/*******************************************************************************/ | |||
/* debug.h | |||
* | |||
* 11/21/2003 - Jonathan Moore Liles | |||
* | |||
* Debuging support. | |||
* | |||
* Disable by defining the preprocessor variable NDEBUG prior to inclusion. | |||
* | |||
* The following macros sould be defined as string literals | |||
* | |||
* name value | |||
* | |||
* __MODULE__ Name of module. eg. "libfoo" | |||
* | |||
* __FILE__ Name of file. eg. "foo.c" | |||
* | |||
* __FUNCTION__ Name of enclosing function. eg. "bar" | |||
* | |||
* (inteter literal) | |||
* __LINE__ Number of enclosing line. | |||
* | |||
* | |||
* __FILE__, and __LINE__ are automatically defined by standard CPP | |||
* implementations. __FUNCTION__ is more or less unique to GNU, and isn't | |||
* strictly a preprocessor macro, but rather a reserved word in the compiler. | |||
* There is a sed script available with this toolset that is able to fake | |||
* __FUNCTION__ (among other things) with an extra preprocesessing step. | |||
* | |||
* __MODULE__ is nonstandard and should be defined the enclosing program(s). | |||
* Autoconf defines PACKAGE as the module name, and these routines will use its | |||
* value instead if __MODULE__ is undefined. | |||
* | |||
* The following routines are provided (as macros) and take the same arguments | |||
* as printf(): | |||
* | |||
* MESSAGE( const char *format, ... ) | |||
* WARNING( const char *format, ... ) | |||
* ASSERTION( const char *format, ... ) | |||
* | |||
* Calling MESSAGE or WARNING prints the message to stderr along with module, | |||
* file and line information, as well as appropriate emphasis. Calling | |||
* ASSERTION will do the same, and then call abort() to end the program. It is | |||
* unwise to supply any of these marcros with arguments that produce side | |||
* effects. As, doing so will most likely result in Heisenbugs; program | |||
* behavior that changes when debugging is disabled. | |||
* | |||
*/ | |||
#ifndef _DEBUG_H | |||
#define _DEBUG_H | |||
#ifndef __MODULE__ | |||
#ifdef PACKAGE | |||
#define __MODULE__ PACKAGE | |||
#else | |||
#define __MODULE__ NULL | |||
#endif | |||
#endif | |||
#ifndef __GNUC__ | |||
#define __FUNCTION__ NULL | |||
#endif | |||
#include <string.h> | |||
#include <stdio.h> | |||
#include <stdarg.h> | |||
typedef enum { | |||
W_MESSAGE = 0, | |||
W_WARNING, | |||
W_ASSERTION | |||
} warning_t; | |||
void | |||
warnf ( warning_t level, | |||
const char *module, | |||
const char *file, | |||
const char *function, size_t line, const char *fmt, ... ); | |||
#ifndef NDEBUG | |||
#define DEBUG( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||
#define ASSERTION( fmt, args... ) ( warnf( W_ASSERTION, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ), abort() ) | |||
#define ASSERT( pred, fmt, args... ) ( do { if ( ! (pred) ) warnf( W_ASSERTION, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmd, ## args ); abort(); } while ( 0 ) ) | |||
#else | |||
#define DEBUG( fmt, args... ) | |||
#define ASSERTION( fmt, args... ) | |||
#define ASSERT( pred, fmt, args... ) | |||
#endif | |||
/* this one's always defined */ | |||
#define MESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||
#define WARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ) | |||
#endif |
@@ -0,0 +1,69 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |||
<html><head> | |||
<meta name="generator" content="Generated by MUP v3.5"> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |||
<link type="text/css" rel="stylesheet" href="mup.css"> | |||
<title>Key Bindings</title> | |||
</head> | |||
<body> | |||
<div id=cover> | |||
<h1>Key Bindings</h1> | |||
<h3></h3> | |||
<address> | |||
<br> | |||
<br> | |||
</address><hr></div> | |||
<div id=body> | |||
<hr width=50%> | |||
<p> | |||
These keys are in effect when the pattern or phrase editor grid is focused. | |||
</p> | |||
<center><div class="fig table"><table id="Fig.1" border=1> | |||
<caption> | |||
<strong>Fig. 1.</strong> Editor Keybindings | |||
</caption> | |||
<tr><th>key</th><th>function</th></tr> | |||
<tr><td>[</td><td>previous</td></tr> | |||
<tr><td>]</td><td>next</td></tr> | |||
<tr><td>1</td><td>horizontal zoom out</td></tr> | |||
<tr><td>2</td><td>horizontal zoom in</td></tr> | |||
<tr><td>3</td><td>vertical zoom out</td></tr> | |||
<tr><td>4</td><td>vertical zoom in</td></tr> | |||
<tr><td>c</td><td>create</td></tr> | |||
<tr><td>d</td><td>duplicate</td></tr> | |||
<tr><td>f</td><td>move to playhead</td></tr> | |||
<tr><td>r</td><td>select range as defined by L and R cursors</td></tr> | |||
<tr><td>q</td><td>select none</td></tr> | |||
<tr><td>C</td><td>crop to range</td></tr> | |||
<tr><td>Delete</td><td>delete selected</td></tr> | |||
<tr><td>Shift-Delete</td><td>clear grid</td></tr> | |||
<tr><td>Arrow keys</td><td>move viewport</td></tr> | |||
<tr><td>Ctrl-Left</td><td>move to previous note</td></tr> | |||
<tr><td>Ctrl-Right</td><td>move to next note</td></tr> | |||
<tr><td><</td><td>move selection left</td></tr> | |||
<tr><td>></td><td>move selection right</td></tr> | |||
<tr><td>,</td><td>move selection up</td></tr> | |||
<tr><td>.</td><td>move selection down</td></tr> | |||
<tr><td>t</td><td>trim length</td></tr> | |||
<tr><td>Space</td><td>toggle transport</td></tr> | |||
<tr><td>m</td><td>mute</td></tr> | |||
<tr><td>s</td><td>solo</td></tr> | |||
</table></div></center> | |||
<center><div class="fig table"><table id="Fig.2" border=1> | |||
<caption> | |||
<strong>Fig. 2.</strong> Gloabl keybindings | |||
</caption> | |||
<tr><th>key</th><th>function</th></tr> | |||
<tr><td>Alt-p</td><td>Switch to pattern editor</td></tr> | |||
<tr><td>Alt-a</td><td>Switch to phrase editor</td></tr> | |||
<tr><td>Alt-s</td><td>Switch to sequence editor</td></tr> | |||
<tr><td>Space</td><td>Toggle transport</td></tr> | |||
<tr><td>Home</td><td>Locate transport to frame 0</td></tr> | |||
</table></div></center> | |||
<p> | |||
Other functions are accessible from the menus or the key is otherwise indicated. | |||
</p> | |||
</div> | |||
</body> | |||
</html> |
@@ -0,0 +1,44 @@ | |||
! title Key Bindings | |||
-- | |||
These keys are in effect when the pattern or phrase editor grid is focused. | |||
// Editor Keybindings | |||
[[ key, function | |||
[[ [, previous | |||
[[ ], next | |||
[[ 1, horizontal zoom out | |||
[[ 2, horizontal zoom in | |||
[[ 3, vertical zoom out | |||
[[ 4, vertical zoom in | |||
[[ c, create | |||
[[ d, duplicate | |||
[[ f, move to playhead | |||
[[ r, select range (as defined by L and R cursors) | |||
[[ q, select none | |||
[[ C, crop to range | |||
[[ Delete, delete selected | |||
[[ Shift-Delete, clear grid | |||
[[ Arrow keys, move viewport | |||
[[ Ctrl-Left, move to previous note | |||
[[ Ctrl-Right, move to next note | |||
[[ \<, move selection left | |||
[[ >, move selection right | |||
[[ \,, move selection up | |||
[[ ., move selection down | |||
[[ t, trim length | |||
[[ Space, toggle transport | |||
[[ m, mute | |||
[[ s, solo | |||
// Gloabl keybindings | |||
[[ key, function | |||
[[ Alt-p, Switch to pattern editor | |||
[[ Alt-a, Switch to phrase editor | |||
[[ Alt-s, Switch to sequence editor | |||
[[ Space, Toggle transport | |||
[[ Home, Locate transport to frame 0 | |||
Other functions are accessible from the menus or the key is otherwise indicated. |
@@ -0,0 +1,199 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |||
<html><head> | |||
<meta name="generator" content="Generated by MUP v3.5"> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |||
<link type="text/css" rel="stylesheet" href="mup.css"> | |||
<title>The Non Sequencer</title> | |||
</head> | |||
<body> | |||
<div id=cover> | |||
<h1>The Non Sequencer</h1> | |||
<h3></h3> | |||
<address> | |||
Jonathan Moore Liles <a href="mailto:wantingwaiting@users.sf.net"><wantingwaiting@users.sf.net></a><br> | |||
Oct 13 2007<br> | |||
</address><a class=ext href="http://non.tuxfamily.org">Home</a><hr></div> | |||
<div id=body> | |||
<hr width=50%> | |||
<h1 id="n:1.">1. Description</h1> | |||
<center><div class="fig image"><table border=1> | |||
<tr><td><img src="non-new-about.png" alt="fig. "></td></tr> | |||
</table></div></center> | |||
<h2 id="n:1.1.">1.1. Guiding Principles</h2> | |||
<ol><li><span>Flexibility</span> | |||
<li><span>Efficiency</span> | |||
<li><span>Purpose</span> | |||
<li><span>Grace</span> | |||
</ol><p> | |||
Non has many modes and functions. Where flexibility comes at a small cost, we prefer to be flexible and make up the difference elsewhere. Where arbitrary limitations are reasonable and necessary, Non enforces them, but not without being forced into it. Where it is easier to be inefficient than efficient, but the efficiency matters, we prefer to put in the (small amount of) work required to be efficient, often resulting in thousand-fold performance gains; this may sound like an obvious statement, but, in fact, design for efficiency is a rare practice in this (Linux Audio<i>'Modern' software</i> arena. Although it is tempting to implement a kitchen sink in every program, we resist the urge. Non has the purpose of being a real-time sequencer and anything outside of that scope is a job for another day. If there is something related to the task at hand that a computer can do instantly and easily, but which requires labor for you, Non tries to do it for you so that you can continue making music without being bothered. Non's user interface is designed to combine the stark functionality and speed of hardware with the degrees of freedom of software. | |||
</p> | |||
<h1 id="n:2.">2. The Interface</h1> | |||
<p> | |||
The interface is quite simple and is based on the excellent FLTK (1.1.x) toolkit. (Versions < 1 of Non were based on raw Xlib and a few Motif widgets.) The author examined many toolkits before beginning, and has absolutely no interest in pursuing GTK or Qt--Non simply doesn't require much of a toolkit, and these are incapable of providing less than total excess. | |||
</p> | |||
<p> | |||
Non's GUI is highly optimized. Common operations are designed to be as fast as possible. Where other sequencers completely monopolize the CPU when scrolling, etc., Non performs smoothly--even on antiquated hardware. It is not technically difficult to achieve such speed. And, in fact, it is a shame that more developers don't consider good (or even just reasonable) performance a priority. | |||
</p> | |||
<h2 id="n:2.1.">2.1. The Pattern Editor</h2> | |||
<center><div class="fig image"><table border=1> | |||
<tr><td><img src="non-pattern-editor.png" alt="fig. "></td></tr> | |||
</table></div></center> | |||
<p> | |||
Upon invocation, Non enters the pattern editor and loads Pattern 1. The pattern editor presents a grid interface--the heart a step sequencer. You can toggle a note on the grid by entering its coordinates with the keyboard or clicking an intersection with the mouse. The length of patterns is unlimited and no special action is required lengthen them (simply adding notes beyond the "end" is enough.) Non can present grids in one of two modes, expanded and compacted. In the compacted view, only named rows are displayed; this means that only the notes the current instrument or scale will consume vertical space--resulting in far more efficient use of screen real-estate. Any notes are made invisible by the compacted view will be silenced. | |||
</p> | |||
<p> | |||
<p> | |||
The resolution of the pattern display can be adjusted (the default is one point per 1/16th note), and, additionally, the canvas can be zoomed horizontally and vertically as necessary. However, it is highly recommended that you avoid creating 'vertical' compositions, that is, one should place each part in a separate pattern and avoid the need to scroll about looking for notes. | |||
</p> | |||
<p> | |||
Tonic patterns have a choice of scale and key, which limits the display to only valid notes. This <i>row-compaction</i> can be turned off, if desired, so that all 128 notes are visible. Or simply choose the <i>chromatic</i> mapping if you are not creating scale based music. | |||
</p> | |||
<p> | |||
Percussion, or other sample-based patterns can be assigned an <i>instrument</i> mapping, which again limits the display to only those notes for which names and volumes have been provided. The instrument definition format is simple ASCII file containing one name, note and volume percentage per line. | |||
</p> | |||
<p> | |||
Individual patterns may be soloed or muted right from the pattern editor. | |||
</p> | |||
<p> | |||
Each pattern has a setting for output MIDI channel and sequencer port--and these may also be changed while the transport is running. | |||
</p> | |||
<h3 id="n:2.1.1.">2.1.1. The Notes</h3> | |||
<p> | |||
The type (duration) of note to be inserted can be adjusted in the pattern editor (control+mouse-wheel). The velocity of individual notes may be adjusted (mouse-wheel), and is the current value is reflected in the color of the note. Ranages may also be <i>inserted</i> and <i>deleted</i>, a commonly required operation during composition, but one that is, sadly, missing from many sequencers. | |||
</p> | |||
<center><div class="fig image"><table border=1> | |||
<tr><td><img src="non-cursors.png" alt="fig. "></td></tr> | |||
</table></div></center> | |||
<h3 id="n:2.1.2.">2.1.2. Recording</h3> | |||
<p> | |||
A pattern can be recorded via MIDI in one of four modes: | |||
</p> | |||
<dl> | |||
<dt><em>Merge (the most familiar/least useful)</em></dt> | |||
<dd>In this mode recorded events are merged into the pattern on each pass through the loop. This is how most sequencers work, but it usually just results in a jumble of notes that require much manual cleaning up.</dd> | |||
<dt><em>Overwrite (each pass [with input] replaces the previous contents of the pattern)</em></dt> | |||
<dd>This is like merge mode, except that the pattern is cleared before the recorded events are input. If note notes have been played during a loop, the pattern remains unchanged. This is a great way to just get a part down without having to remove your hands from the instrument.</dd> | |||
<dt><em>Layer (each pass [with input] goes into a new pattern)</em></dt> | |||
<dd>This is just like overwrite mode, except that the pattern actually overwritten is a duplicate. Use this mode to record several loops of the same length without removing your hands from the instrument.</dd> | |||
<dt><em>New</em></dt> | |||
<dd>In this mode, all recorded events are placed into a new pattern (of whatever length) when recording is stopped.</dd> | |||
</dl> | |||
<h3 id="n:2.1.3.">2.1.3. The Event Editor</h3> | |||
<center><div class="fig image"><table border=1> | |||
<tr><td><img src="non-event-editor-notes.png" alt="fig. "></td></tr> | |||
</table></div></center> | |||
<p> | |||
For situations requiring close inspection, fine-adjustments or entering of non-note data, the Event Editor allows one to edit the raw MIDI event list of a pattern. A common use is to insert program or control change events. | |||
</p> | |||
<p> | |||
Like everything else in Non, the Event Editor is real-time--change a note and you'll see and hear the result as the pattern plays. | |||
</p> | |||
<h2 id="n:2.2.">2.2. The Phrase Editor</h2> | |||
<p> | |||
Phrases are to patterns as patterns are to notes. Switching to the Phrase Editor brings up Phrase 1, where each row corresponds to an existing <i>pattern</i>. The grid of the Phrase Editor is fixed at one column-per-beat. This view is somewhat similar to a timeline view in other sequencers, but do not be deceived--Phrases may be many in number and are triggered just like patterns. | |||
</p> | |||
<p> | |||
When a node on the Phrase Editor grid is activated, the length of the cue event inserted will be the same as that of the pattern being triggered. Adjusting the duration of this event will cause the pattern be cut short or looped. If the length of a referenced pattern is changed, this will <b>not</b> be reflected in the Phrase display. You must either re-insert or adjust the length of the reference. | |||
</p> | |||
<p> | |||
It is recommended that, to avoid confusion, you first compose all of the patterns you need for a phrase, and only then bring up the phrase editor. | |||
</p> | |||
<p> | |||
Editing operations are the same as those for the Pattern Editor. | |||
</p> | |||
<h2 id="n:2.3.">2.3. The Sequence Editor</h2> | |||
<p> | |||
The Sequence Editor defines the sequence of playback. The interface is a list of phrases, to be played sequentially, beginning from bar 1. It is not necessary to include all existing phrases in the playlist. Phrases can be moved up and down the playlist, inserted and deleted. The editor displays the start bar of each phrase in addition to its number and name. | |||
</p> | |||
<p> | |||
This sequence->phrase->pattern hierarchy allows for logical, expressive compositions--without the labor intensive copy<i>paste</i>duplicate work-flow imposed by other sequencers. | |||
</p> | |||
<p> | |||
For example, suppose you have a song with a 12 bar progression that repeats 4 times. This 12 bar sequence is composed of many patterns, each a few measures in length and roughly corresponding to the chords in the progression. | |||
</p> | |||
<p> | |||
In another sequencer you would be required to use clumsy copy/paste operations to destructively extend the 12 bar sequence. Then if you wanted to change a part of that subsequence later, you would have to go edit each instance of it on the 'timeline' view. This is absurdly inefficient for the operator. | |||
</p> | |||
<p> | |||
In Non you simply create your patterns, assemble them into logical phrases, and then assemble these phrases into a sequence that determines the entire song. This approach is similar to the bottom-up approach of factored languages such as Forth. | |||
</p> | |||
<h2 id="n:2.4.">2.4. Pattern Triggers</h2> | |||
<center><div class="fig image"><table border=1> | |||
<tr><td><img src="non-pattern-triggers.png" alt="fig. "></td></tr> | |||
</table></div></center> | |||
<p> | |||
Next to the sequence playlist is an array of pattern triggers. Here one can monitor the progress of multiple patterns during playback and cause them to be muted etc. | |||
</p> | |||
<p> | |||
The left mouse button toggles muting, the middle button toggles soloing, and the right button brings up the given pattern in the pattern editor. | |||
</p> | |||
<p> | |||
Playing patterns appear green, the solo pattern appears red, and muted patterns appear gray, | |||
</p> | |||
<h1 id="n:3.">3. MIDI</h1> | |||
<h2 id="n:3.1.">3.1. IO</h2> | |||
<p> | |||
Non utilizes the Jack MIDI transport. Jack MIDI is an emerging MIDI transport for Linux. Since Jack already provides similar routing as the ALSA Sequencer interface, little is lost--besides compatibility with existing programs. (Jack has an aseq bridge capability, but in order to benefit from Jack MIDI, both sequencer and synth must use Jack). The Jack MIDI API is extremely limited in comparison to the very capable ALSA API, but this is a problem for the programmer, not the user. | |||
</p> | |||
<p> | |||
At the time of writing, Non is one of only two sequencers to use Jack MIDI natively. | |||
</p> | |||
<h2 id="n:3.2.">3.2. Non Files</h2> | |||
<p> | |||
The format of <tt>.non</tt> files is a variation of SMF-2. In an SMF-2 file, each track chunk represents a pattern. Because Non groups patterns into <i>phrases</i>, this usage of SMF-2 is probably not compatible with other implementations (although, the author has never actually seen another program that could play back SMF-2 anyway.) | |||
</p> | |||