Re: [LAD] Writing a library?

2008-09-05 Thread Anders Dahnielson
On Sat, Jul 26, 2008 at 00:03, Anders Dahnielson [EMAIL PROTECTED]wrote:



 On Wed, Jul 23, 2008 at 18:13, Anders Dahnielson [EMAIL PROTECTED]wrote:


 Here's a simple tokenizer for SFZ I wrote once upon a time in Python. Not
 sure if I got it completely right.


 Nope. E.g. it matches lokey= twice (once as lokey= with a value and as key=
 without a value). *Blushes*. LOL.


Ok, this is now an old thread. But to not appear as a complete fool I will
post some code that actually works. ;-)

[BEGIN PYTHON]

import sys

def parse(f):
token_stack = []
string_stack = []
for line in f:
# COMMENT
if line.startswith('//'):
continue
# DEFINITION
for token in line.split():
if token.startswith('') and token.endswith(''):
# HEAD
if string_stack:
token_stack.append( .join(string_stack))
string_stack[:] = []
string_stack.append(token)
elif token.find('=') != -1:
# HEAD
if string_stack:
token_stack.append( .join(string_stack))
string_stack[:] = []
string_stack.append(token)
else:
# TAIL
string_stack.append(token)
# EOL
if string_stack:
token_stack.append( .join(string_stack))
string_stack[:] = []
return token_stack

if __name__ == '__main__':
sfzf = open(sys.argv[1], 'r')
print parse(sfzf)
sfzf.close()

[END PYTHON]

-- 
Anders Dahnielson
[EMAIL PROTECTED]
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-25 Thread Anders Dahnielson
On Wed, Jul 23, 2008 at 18:13, Anders Dahnielson [EMAIL PROTECTED]wrote:


 Here's a simple tokenizer for SFZ I wrote once upon a time in Python. Not
 sure if I got it completely right.


Nope. E.g. it matches lokey= twice (once as lokey= with a value and as key=
without a value). *Blushes*. LOL.

-- 
Anders Dahnielson
[EMAIL PROTECTED]
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Nedko Arnaudov
Julien Claassen [EMAIL PROTECTED] writes:

 Hi!
Yes the autotools are good. cmake might be better, but it is not as well 
 known and often used as autotools and scons.
As I heard scons should be enough for a lot of things. Even for multi 
 platform stuff. Csound uses it and seems fine with it and a couple more linux 
 (multiplatform) applications like ardour.
my choice would always be between autoconf/automake/et al. and scons. For 
 both learning is necessary. For scons it's python and for the autotools it's 
 the macro-language. Both seems to have nice reference docs...

I'd sugeest you waf, takes goods sides of autotools (separate configure
stage), scons (python) and cmake (nice progress indication). And even
has good features that are unique. Like. waf being part of source tree,
thus multiple developers cannot end with having different versions of
the build tool.

-- 
Nedko Arnaudov GnuPG KeyID: DE1716B0


pgpXmrgodW6UA.pgp
Description: PGP signature
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Emanuel Rumpf
2008/7/23 Nedko Arnaudov [EMAIL PROTECTED]:
 I'd sugeest you waf, takes goods sides of autotools (separate configure
 stage), scons (python) and cmake (nice progress indication). And even
 has good features that are unique. Like. waf being part of source tree,
 thus multiple developers cannot end with having different versions of
 the build tool.

the link:
http://code.google.com/p/waf/
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Joshua Boyd

On Jul 22, 2008, at 10:26 PM, Darren Landrum wrote:

 I've been looking around for a library to read and write SFZ files,
 which is an open sampler format released by Cakewalk:

 http://www.cakewalk.com/DevXchange/sfz.asp

 Finding none, I thought I might try my hand at writing a library for
 this myself, as there is no embedded wave information like with Gig
 files. SFZ is simply a text file to be parsed.

 Now, I know about writing a good header file, and its associated  
 class,
 and all that, but I have no knowledge of how to write it as a dynamic
 library. Google searches on every possible permutation have been
 worthless to me as well.

 I would prefer to write it in C++, as that's what I know, and even  
 then,
 not too well, hence why I thought I'd start with something simple like
 parsing a text file. If anyone has any advice, recommendations, or
 ideas, I'll happily listen and learn. I have yet to think too much  
 about
 how the data will be stored in the class, and what methods to make
 available to access it, so if anyone knows any best practices  
 there, I'd
 really like to know. Consider this a feeler post.

I'd strongly suggest you consider learning C if you want to maximize  
other people using your library.  If you write the library in C++ it  
will be hard for anyone but C++ users to use it.  If you write it in  
straight C, or at least expose a plain C interface, it will be  
trivial to use for C users, C++ users, Objective C users, Python  
users, Smalltalk users and some scheme and lisp users, and I'm sure  
I'm missing other languages that can interface with C easily.

Also, I suggest that you learn how to use a lex program like Flex.   
You could also possibly use a parser generator, something like yacc/ 
bison on top of that.  The time spent learning flex will be time very  
well spent and the time spent learning it will probably pay itself  
back immediately as your write your tokenizer.  There are quite a few  
good free lex and/or yacc guides available, often on university web  
sites.
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Paul Davis

On Wed, 2008-07-23 at 08:41 -0400, Joshua Boyd wrote:

 
 I'd strongly suggest you consider learning C if you want to maximize  
 other people using your library.  If you write the library in C++ it  
 will be hard for anyone but C++ users to use it.  If you write it in  
 straight C, or at least expose a plain C interface, it will be  
 trivial to use for C users, C++ users, Objective C users, Python  
 users, Smalltalk users and some scheme and lisp users, and I'm sure  
 I'm missing other languages that can interface with C easily.

good advice.

 Also, I suggest that you learn how to use a lex program like Flex.   
 You could also possibly use a parser generator, something like yacc/ 
 bison on top of that.  The time spent learning flex will be time very  
 well spent and the time spent learning it will probably pay itself  
 back immediately as your write your tokenizer.  There are quite a few  
 good free lex and/or yacc guides available, often on university web  
 sites.

in my experience, not so good advice. lexer+parser generators are great
for certain kinds of things, actually more like indispensable. but for
parsing audio files, they really are not very well suited for the task. 
these are binary files with no real semantic structure other than
chunks. i have no doubt that you could use them, but erik de castro
lopo didn't for libsndfile and thats good enough for me :)

--p


___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Paul Davis

On Wed, 2008-07-23 at 09:02 -0400, Paul Davis wrote:

 in my experience, not so good advice. lexer+parser generators are great
 for certain kinds of things, actually more like indispensable. but for
 parsing audio files, they really are not very well suited for the task. 
 these are binary files with no real semantic structure other than
 chunks. i have no doubt that you could use them, but erik de castro
 lopo didn't for libsndfile and thats good enough for me :)

i've been informed that i am ignorant and should keep my mouth closed
about things like SFZ that i don't know much about :) (in the nicest
possible way of course!) so ignore me ..

--p


___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Joshua Boyd
On Wed, Jul 23, 2008 at 03:25:47PM +0200, Julien Claassen wrote:
 Hi!
   Paul: As I understood the sfz format is text-based. I didn't take a look. 
 But depending on what it looks like, a parser generator might be good 
 advice.
   If the SFZ is an xml variant libxml might be better suited.

I looked at the page and it is not XML. 
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread gordonjcp
On Wed, Jul 23, 2008 at 03:25:47PM +0200, Julien Claassen wrote:
 Hi!
Paul: As I understood the sfz format is text-based. I didn't take a look. 
 But depending on what it looks like, a parser generator might be good advice.
If the SFZ is an xml variant libxml might be better suited.
Kindest regards
   Julien

It's not XML, it's a sort of flat-text-ish thing with various keywords
for setting keys, keygroups, mutegroups and so on.

Having briefly skimmed the spec over lunch, I'm not in much of a
position to say how good it is, but it looks right.

Essentially an SFZ file is a text file describing what to do with a
bunch of .wav or .ogg files.  It's almost worryingly clueful.

Gordon
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Darren Landrum
[EMAIL PROTECTED] wrote:
 It's not XML, it's a sort of flat-text-ish thing with various keywords
 for setting keys, keygroups, mutegroups and so on.
 
 Having briefly skimmed the spec over lunch, I'm not in much of a
 position to say how good it is, but it looks right.
 
 Essentially an SFZ file is a text file describing what to do with a
 bunch of .wav or .ogg files.  It's almost worryingly clueful.

It wasn't actually created by Cakewalk, but by a small company that 
Cakewalk had bought, and rather than closing up or quelching SFZ, they 
decided to keep it open. That's the story best as I was able to divine 
it, anyway. And now with the news that Tascam is discontinuing all 
Gigastudio-related development (http://www.filmmusicmag.com/?p=1738 and 
confirmed on the Legacy section of Tascam's web site: 
http://www.tascam.com/legacy;37,7.html) it's possible that SFZ might 
become a new standard for sample libraries to use. Garritan is 
apparently releasing, or getting set to release, their libraries in SFZ now.

My issue now, though, is I clearly do not have the skills to create a 
good, usable library. Nor do I want to; I'd rather spend that time 
creating a working application, even if it's a monolithic one. I'm here 
because I'm broke and scratching my own itch. If I had the money, I'd go 
off and buy NI Komplete and be happy actually making music. It can be 
argued that learning programming and DSP is making me a better person, 
but it certainly isn't making me a happier one.

So now I'm working out a plan for a code framework for making software 
synths and samplers, likely directed graph based. I might release that 
framework separately, but no one will likely get a library out of me. I 
can only do what I can do with the tools I have, and scratching my own 
itch comes first.

Maybe someone with those skills would like to jump in and help? I 
realize that code says more on this forum than talk, but surely I can 
try to gather a team together for a larger project. Right? Maybe?

-- Darren Landrum
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Darren Landrum
Julien Claassen wrote:
 Hi Darren!
   I'd still suggest on going linuxsampler. There's a basic framework 
 already. I'm not the skillful programmer myself, otherwise I'd like to 
 help. But reasons for my point:
 1. LS has already MIDI and audio drivers working.
 2. LS offers a clear structure and an API to go by.
 3. LS is in use already.
 4. It already has two GUIs and is probably getting more.
 5. MY OWN HERE: It's useable for blind people as well with relative ease.
 6. I think the people there are a helpful and nice crowd.
   So six nice reasons to go that way. Perhaps you can also rely on code 
 already written, like take a look and produce similar code in parts and 
 there are people who know the framework and the matter. and it won't be 
 another standalone app to maintain and adapt to every novation in the 
 audio-world, like audio/MIDI driver APIs changing etc...
   One of the delicate remarks: If you don't get along well with 
 LinuxSampler's license, you could make your engine a seperate package 
 and say it's LGPL. Is tht correct? Some backup. No licensing discussion 
 just a true or false statement. PLEASE! :-)
   Kindest regards
  Julien

I'm not a CS person, I'm a math and engineering person. I truly and 
honestly believe that it will be easier for me to start from scratch 
than to try to wrap my head around someone else's codebase.

That being said, I mentioned starting with a code framework that would 
allow the creation of any kind of synth or sampler, not just the one I 
have in mind (which is inspired by the upcoming Omnisphere more than 
anything else). I may not be a CS guy, but I do understand the value of 
planning in advance.

Nevertheless, anyone who quotes John Miles in his sig must be a cool 
person, so I'll certainly wait a bit for other ideas and advice before 
barreling off on my own. Thank you for the reply.

-- Darren Landrum
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Anders Dahnielson
On Wed, Jul 23, 2008 at 16:41, Darren Landrum [EMAIL PROTECTED]
wrote:

 [EMAIL PROTECTED] wrote:
  It's not XML, it's a sort of flat-text-ish thing with various keywords
  for setting keys, keygroups, mutegroups and so on.
 
  Having briefly skimmed the spec over lunch, I'm not in much of a
  position to say how good it is, but it looks right.
 
  Essentially an SFZ file is a text file describing what to do with a
  bunch of .wav or .ogg files.  It's almost worryingly clueful.

 It wasn't actually created by Cakewalk, but by a small company that
 Cakewalk had bought, and rather than closing up or quelching SFZ, they
 decided to keep it open. That's the story best as I was able to divine
 it, anyway. And now with the news that Tascam is discontinuing all
 Gigastudio-related development (http://www.filmmusicmag.com/?p=1738 and
 confirmed on the Legacy section of Tascam's web site:
 http://www.tascam.com/legacy;37,7.html) it's possible that SFZ might
 become a new standard for sample libraries to use. Garritan is
 apparently releasing, or getting set to release, their libraries in SFZ
 now.


Hi Darren! :-)

Note that Garritan/Plogue are using a later version of the SFZ format with
additional and sometimes custom opcodes in their ARIA player. (See e.g.
http://www.northernsounds.com/forum/showthread.php?t=60929 )

Here's a simple tokenizer for SFZ I wrote once upon a time in Python. Not
sure if I got it completely right.

[BEGIN PYTHON]

import sys

def find_delimiter(string, delimiter):
Find all occurences of delimiter.
start, i, ndx = 0, 0, []
while True:
i = string.find(delimiter, start)
if i != -1:
start = i + 1
ndx.append((i, delimiter))
else:
break
return ndx

def find_all_delimiters(string, delimiters):
Find all delimiters.
ndx = []
for delimiter in delimiters:
ndx.extend(find_delimiter(string, delimiter))
return ndx

def tokenize_sfz(string):
Tokenize SFZ string.
delimiters = [
# comments
'\n',
'//',
# headers
'region',
'group',
# sample definition
'sample=',
# input controls
'lochan=', 'hichan=',
'lokey=', 'hikey=', 'key=',
'lovel=', 'hivel=',
'lobend=', 'hibend=',
'locahnaft=', 'hichanaft=',
'lopolyaft=', 'hiplyaft=',
'lorand=', 'hirand=',
'lobpm=', 'hibmp=',
'seq_length=', 'seq_position=',
'sw_lokey=', 'sw_hikey=', 'sw_last=', 'sw_down=', 'sw_up=',
'sw_previous=', 'sw_vel=',
'trigger=',
'group=',
'off_by=', 'off_mode=',
] + [
'on_locc%d=' % cc for cc in range(128)
] + [
'on_locc%d=' % cc for cc in range(128)
] + [
# performance parameters
'delay=', 'delay_random=',
] + [
'delay_cc%d=' % cc for cc in range(128)
] + [
'offset=', 'offset_random=',
] + [
'offset_cc%d=' % cc for cc in range(128)
] + [
'end=',
'count=',
'loop_mode=', 'loop_start=', 'loop_end=',
'sync_beats=', 'sync_offset=',
# pitch
'transpose=',
'tune=',
'pitch_keycenter=', 'pitch_keytrack=', 'pitch_veltrack=',
'pitch_random=',
'bend_up=', 'bend_down=', 'bend_step=',
# pitch eg
'pitcheg_delay=',
'pitcheg_start=',
'pitcheg_attack=',
'pitcheg_hold=',
'pitcheg_decay=',
'pitcheg_sustain=',
'pitcheg_release=',
'pitcheg_depth=',
'pitcheg_vel2delay=',
'pitcheg_vel2attack=',
'pitcheg_vel2hold=',
'pitcheg_vel2decay=',
'pitcheg_vel2sustain=',
'pitcheg_vel2realease=',
'pitcheg_vel2depth=',
# pitch lfo
'pitchlfo_delay=',
'pitchlfo_fade=',
'pitchlfo_freq=',
'pitchlfo_depth=',
] + [
'pitchlfo_depthcc%d=' % cc for cc in range(128)
] + [
'pitchlfo_depthchanaft=',
'pitchlfo_depthpolyaft=',
] + [
'pitchlfo_freqcc%d=' % cc for cc in range(128)
] + [
'pitchlfo_freqchanaft=',
'pitchlfo_freqpolyaft=',
# filter
'fil_type=',
'cutoff=',
] + [
'cutoff_cc%d=' % cc for cc in range(128)
] + [
'cutoff_chanaft=', 'cutoff_polyaft=',
'resonance=',
'fil_keytrack=', 'fil_keycenter=', 'fil_veltrack=', 'fil_random=',
# filter eg
'fileg_delay=',
'fileg_start=',
'fileg_attack=',
'fileg_hold=',
'fileg_decay=',
'fileg_sustain=',
'fileg_release=',
'fileg_depth=',
'fileg_vel2delay=',
'fileg_vel2attack=',
'fileg_vel2hold=',
'fileg_vel2decay=',
'fileg_vel2sustain=',
'fileg_vel2realease=',
'fileg_vel2depth=',
# filter lfo
'fillfo_delay=',
'fillfo_fade=',
 

Re: [LAD] Writing a library?

2008-07-23 Thread Anders Dahnielson
On Wed, Jul 23, 2008 at 15:25, Julien Claassen [EMAIL PROTECTED] wrote:

 Hi!
   Paul: As I understood the sfz format is text-based. I didn't take a look.
 But depending on what it looks like, a parser generator might be good
 advice.
   If the SFZ is an xml variant libxml might be better suited.
   Kindest regards
  Julien


Here's what a snippet from a SFZ file looks like:

[BEGIN SFZ]

/
// Region Name: NOTE E_

region
sample=E_1.wav
key=52
lovel=111 hivel=127

region
sample=E_2.wav
key=52
lovel=86 hivel=110

region
sample=E_3.wav
key=52
lovel=71 hivel=85

region
sample=E_4.wav
key=52
lovel=0 hivel=70


/
// Region Name: NOTE F_

region
sample=F_1.wav
key=53
lovel=111 hivel=127

region
sample=F_2.wav
key=53
lovel=86 hivel=110

region
sample=F_3.wav
key=53
lovel=71 hivel=85

region
sample=F_4.wav
key=53
lovel=0 hivel=70

[END SFZ]

-- 
Anders Dahnielson
[EMAIL PROTECTED]
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev


Re: [LAD] Writing a library?

2008-07-23 Thread Pelle Nilsson
Anders Dahnielson [EMAIL PROTECTED] writes:

 Here's a simple tokenizer for SFZ I wrote once upon a time in Python. Not
 sure if I got it completely right.

*snip*

I was just about to suggest checking out the
sampler/synth/sequencer/tracker engine libzzub, that happens to
include Python bindings:

http://trac.zeitherrschaft.org/zzub/
http://trac.zeitherrschaft.org/aldrin

I haven't looked much at it myself yet, but Aldrin works very well
(built on top of libzzub) and it seems like a good design, supporting
different types of plugins and audio outputs and handling sequencing
and the directed graph of plugins.

-- 
/Pelle
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev