"hello world" for pure-audio and pure-midi

13 views
Skip to first unread message

Bjoern Lindig

unread,
Mar 24, 2011, 4:53:24 PM3/24/11
to pure...@googlegroups.com
Hi,

does anybody have an example he could share using audio and/or midi? It
would help me a lot for my pure studies. I tried to look at the files
audio.pure and midi.pure but it would be great to have an example to
test and as a startoff for playing arround.

Thanks a lot.

Best, Bjoern

Albert Graef

unread,
Mar 26, 2011, 5:38:57 AM3/26/11
to pure...@googlegroups.com
Hi Bjoern,

> does anybody have an example he could share using audio and/or midi? It
> would help me a lot for my pure studies. I tried to look at the files
> audio.pure and midi.pure but it would be great to have an example to
> test and as a startoff for playing arround.

You can find some examples in the pure-midi and pure-audio packages:

http://code.google.com/p/pure-lang/source/browse/pure-audio/examples/audio_examp.pure
http://code.google.com/p/pure-lang/source/browse/pure-midi/examples/midi_examp.pure

These show how to read and write audio and MIDI devices in realtime, and
also how to read and play back audio and midi in a file. Writing audio
and midi to a file should be rather straightforward, too, but isn't
covered in the examples right now; if you need any help with that, just ask.

Albert

--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email: Dr.G...@t-online.de, a...@muwiinfa.geschichte.uni-mainz.de
WWW: http://www.musikinformatik.uni-mainz.de/ag

Bjoern Lindig

unread,
Mar 27, 2011, 3:02:25 PM3/27/11
to pure...@googlegroups.com
Hi Albert,

thanks for your reply. Sorry, I rushed through installation so that I
overlooked the examplefiles. They are exactly what I was looking for!

There is one small issue anyway. I get a list of errors when trying to
load the libsndfile:
> using sndfile;
sndfile.pure, line 161: external symbol 'sf_error' cannot be found
...

37 Lines of errors not finding functions from sndfile. The header file
is in /usr/include/sndfile.h. How can I make shure, pure finds it and
uses it? Is there anything else I might have missed?

Many thanks!

Bjoern

> --
> You received this message because you are subscribed to the Google Groups "pure-lang" group.
> To post to this group, send email to pure...@googlegroups.com.
> To unsubscribe from this group, send email to pure-lang+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pure-lang?hl=en.
>

Albert Graef

unread,
Mar 28, 2011, 10:28:23 AM3/28/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
> There is one small issue anyway. I get a list of errors when trying to
> load the libsndfile:
> > using sndfile;
> sndfile.pure, line 161: external symbol 'sf_error' cannot be found

That seems to indicate that libsndfile was linked in it properly, but
then you should also get an error message about that. What does the
following command give you?

using "lib:sfinfo";

Also, what system do you run this on? Which libsndfile version?

> 37 Lines of errors not finding functions from sndfile. The header file
> is in /usr/include/sndfile.h. How can I make shure, pure finds it and
> uses it? Is there anything else I might have missed?

The header file isn't needed (unless you have to rebuild the wrapper),
only libsndfile.so.

Albert Graef

unread,
Mar 28, 2011, 10:30:26 AM3/28/11
to pure...@googlegroups.com
Albert Graef wrote:
> That seems to indicate that libsndfile was linked in it properly, but

s/was/wasn't/

Bjoern Lindig

unread,
Mar 28, 2011, 4:15:37 PM3/28/11
to pure...@googlegroups.com
On Mon, Mar 28, 2011 at 04:28:23PM +0200, Albert Graef wrote:
> Bjoern Lindig wrote:
> > There is one small issue anyway. I get a list of errors when trying to
> > load the libsndfile:
> > > using sndfile;
> > sndfile.pure, line 161: external symbol 'sf_error' cannot be found
>
> That seems to indicate that libsndfile was linked in it properly, but
> then you should also get an error message about that. What does the
> following command give you?
>
> using "lib:sfinfo";

it gives nothing. What should it give?

>
> Also, what system do you run this on? Which libsndfile version?

Oh, sorry I didn't mention: This is archlinux on a x86_64 Intel Core2Duo,
kernel 2.6.37 with libsndfile 1.0.23-1 and pure is 0.46-1


>
> > 37 Lines of errors not finding functions from sndfile. The header file
> > is in /usr/include/sndfile.h. How can I make shure, pure finds it and
> > uses it? Is there anything else I might have missed?
>
> The header file isn't needed (unless you have to rebuild the wrapper),
> only libsndfile.so.

this file is in /usr/lib/. I tried to link it to
/usr/local/lib/libsndfile.so but it did not change anything. I
recompiled both, pure and pure-audio and there was no error during
compile time.

Best,

Bjoern


>
> Albert
>
> --
> Dr. Albert Gr"af
> Dept. of Music-Informatics, University of Mainz, Germany
> Email: Dr.G...@t-online.de, a...@muwiinfa.geschichte.uni-mainz.de
> WWW: http://www.musikinformatik.uni-mainz.de/ag
>

Albert Graef

unread,
Mar 29, 2011, 12:32:51 AM3/29/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
>> using "lib:sfinfo";
>
> it gives nothing. What should it give?

That's fine. Does this work, too?

using "lib:libsndfile";
extern int sf_error(SNDFILE*);

> Oh, sorry I didn't mention: This is archlinux on a x86_64 Intel Core2Duo,
> kernel 2.6.37 with libsndfile 1.0.23-1 and pure is 0.46-1

The libsndfile is newer than what I have here, I'll have to give it a go.

Bjoern Lindig

unread,
Mar 29, 2011, 4:10:37 AM3/29/11
to pure...@googlegroups.com
On Tue, Mar 29, 2011 at 06:32:51AM +0200, Albert Graef wrote:
> > it gives nothing. What should it give?
>
> That's fine. Does this work, too?
>
> using "lib:libsndfile";

This works.

> extern int sf_error(SNDFILE*);
>
But this gives an error:

<stdin>, line 2: unknown C type 'in'

Thanks for your help!

Bjoern

Albert Graef

unread,
Mar 29, 2011, 6:39:51 AM3/29/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
>> extern int sf_error(SNDFILE*);
>>
> But this gives an error:
>
> <stdin>, line 2: unknown C type 'in'

Please double-check. You need to type the line exactly as given (best to
copy and paste it). It's 'extern int', not 'extern in'. Do you still get
this error?

Bjoern Lindig

unread,
Mar 29, 2011, 9:20:04 AM3/29/11
to pure...@googlegroups.com
On Tue, Mar 29, 2011 at 12:39:51PM +0200, Albert Graef wrote:
> Bjoern Lindig wrote:
> >> extern int sf_error(SNDFILE*);
> >>
> > But this gives an error:
> >
> > <stdin>, line 2: unknown C type 'in'
>
> Please double-check. You need to type the line exactly as given (best to
> copy and paste it). It's 'extern int', not 'extern in'. Do you still get
> this error?
>
> --
Ups, sorry. I like typing things in to get used to pures syntax, but it seems
here this habit is a little bit missplaced.

No error for this:

> using "lib:libsndfile";
> extern int sf_error(SNDFILE*);

Best, Bjoern

Albert Graef

unread,
Mar 29, 2011, 11:07:41 AM3/29/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
> No error for this:
>
>> using "lib:libsndfile";
>> extern int sf_error(SNDFILE*);

Ok, that's fine. Next, with the pure-audio stuff installed, please try:

using "lib:libsndfile";
using sndfile;

If that doesn't give any errors either, then restart the Pure
interpreter and try this again:

using sndfile;

Does that still give you the same errors that you had previously? In
that case, I need a complete error log, as well as a log of your build
of pure-audio (i.e., what's printed when you run 'make && sudo make
install' in the pure-audio directory, using a pristine copy of the
sources; please attach that as a text file). I also need to know what
gcc version you're using (gcc --version).

Albert

Albert Graef

unread,
Mar 29, 2011, 11:18:29 AM3/29/11
to pure...@googlegroups.com
Also, while you're at it, please post the output of the following command:

ldd /usr/local/lib/pure/sfinfo.so

(Assuming that you installed the Pure stuff including pure-audio under
/usr/local, otherwise adjust the path accordingly.)

Bjoern Lindig

unread,
Mar 29, 2011, 2:31:27 PM3/29/11
to pure...@googlegroups.com
Hi Albert,

thanks again for helping me!

On Tue, Mar 29, 2011 at 05:07:41PM +0200, Albert Graef wrote:
> Ok, that's fine. Next, with the pure-audio stuff installed, please try:
>
> using "lib:libsndfile";
> using sndfile;

There is no error here.


>
> If that doesn't give any errors either, then restart the Pure
> interpreter and try this again:
>
> using sndfile;

Same error as before (pure.log).


>
> Does that still give you the same errors that you had previously? In
> that case, I need a complete error log, as well as a log of your build

pure.log, pure-audio_make.log, pure-audio_make_install.log

> of pure-audio (i.e., what's printed when you run 'make && sudo make
> install' in the pure-audio directory, using a pristine copy of the
> sources; please attach that as a text file). I also need to know what
> gcc version you're using (gcc --version).

gcc (GCC) 4.5.2 20110127 (prerelease)

I also attached the log of the build of pure and of course the ldd log.
For me it is /usr/lib/pure/sfinfo.so, right?

As it was built on archlinux everything is made in the fakeroot environment. Could that
have any impact on the error?

Best, Bjoern

libsndfile_error.tar.gz

Albert Graef

unread,
Mar 29, 2011, 4:50:25 PM3/29/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
> As it was built on archlinux everything is made in the fakeroot environment. Could that
> have any impact on the error?

The problem is with the linkage options, specifically -Wl,--as-needed.
sfinfo.so is supposed to pull in libsndfile.so, but as the ldd.log
clearly shows, it doesn't, which is because of this option. You'll need
to figure out how to build your packages without this option, otherwise
you'll get similar errors with many Pure modules. Presumably this option
gets set in the build environment through the LDFLAGS environment
variable; your build tools should provide you with a way to set LDFLAGS
in some way (just setting LDFLAGS to empty should work fine).

HTH,

Bjoern Lindig

unread,
Mar 29, 2011, 7:19:36 PM3/29/11
to pure...@googlegroups.com
Hi Albert,

it is exactly as you said. I decided to add -Wl,--no-as-needed to the
LDFLAGS variable. I thought that is this would be the most clean way to
remove the --as-needed as I can simply add it into the PKGBUILD skript
and don't have to change the configuration of the whole package system.
The advantage is that I can share the package and provide access to this
very great software to others. The cc comand now looks a little strange
but the result is a working package:

cc -shared -o audio.so audio.c -g -O2 -fPIC -Wl,--hash-style=gnu -Wl,--as-neede
d -Wl,--no-as-needed -lportaudio -lpthread -lpure

Is there something I should have in mind using controversal options
during the build process or would you say it is ok as long as it works?
I'm not at all shure because the whole linkage thing is still a closed
book for me.

Thanks for your help and the patience.

Bjoern

Albert Graef

unread,
Mar 30, 2011, 5:16:35 AM3/30/11
to pure...@googlegroups.com
Bjoern Lindig wrote:
> it is exactly as you said. I decided to add -Wl,--no-as-needed to the
> LDFLAGS variable.

Is the -Wl,--as-needed standard on ArchLinux now? Then I guess that
we'll have to prepare for more error reports like yours in the future.

> Is there something I should have in mind using controversal options
> during the build process or would you say it is ok as long as it works?

I'm not familiar with ArchLinux's build system and packaging policies,
so I'd say that you should discuss the problem with the AUR maintainers
(or whoever is in charge) if you want to make these packages available
to others. If there's something that I can do upstream to make the Pure
stuff just work on ArchLinux without having to fiddle with the linker
flags, just let me know.

BTW, I don't know whether you are aware of this, but I just remembered
that there already are some Pure-related packages up on AUR, maybe you
should take a look at these first and/or get in touch with the
corresponding package maintainers:

http://aur.archlinux.org/packages.php?ID=22893

(That's the entry for the main package. You can find the other
Pure-related packages by following the links under "Required by". The
above link is also on the Pure website.)

> Thanks for your help and the patience.

You're welcome. :) Happy Pure programming.

Albert Graef

unread,
Mar 30, 2011, 5:55:21 AM3/30/11
to pure...@googlegroups.com
Albert Graef wrote:
> Bjoern Lindig wrote:
>> it is exactly as you said. I decided to add -Wl,--no-as-needed to the
>> LDFLAGS variable.
>
> Is the -Wl,--as-needed standard on ArchLinux now? Then I guess that
> we'll have to prepare for more error reports like yours in the future.

Thinking about this some more, I've come to the conclusion that it's
probably best to solve this once and for all upstream, by just adding a
fake dependency on the base libraries where needed. It's also a good
opportunitiy to do this now, as I'm about to release new versions of
most modules in the wake of the Pure 0.47 release anyway. So you don't
need to take any action right now, I'll let you know when I'm done with
this.

Bjoern Lindig

unread,
Mar 30, 2011, 11:09:57 AM3/30/11
to pure...@googlegroups.com
On Wed, Mar 30, 2011 at 11:55:21AM +0200, Albert Graef wrote:
> Thinking about this some more, I've come to the conclusion that it's
> probably best to solve this once and for all upstream, by just adding a
> fake dependency on the base libraries where needed. It's also a good
> opportunitiy to do this now, as I'm about to release new versions of
> most modules in the wake of the Pure 0.47 release anyway. So you don't
> need to take any action right now, I'll let you know when I'm done with
> this.
>
> Albert

Cool, thank you!

Bjoern

Albert Graef

unread,
Mar 30, 2011, 5:26:58 PM3/30/11
to pure...@googlegroups.com
Albert Graef wrote:
> Thinking about this some more, I've come to the conclusion that it's
> probably best to solve this once and for all upstream, by just adding a
> fake dependency on the base libraries where needed. It's also a good
> opportunitiy to do this now, as I'm about to release new versions of
> most modules in the wake of the Pure 0.47 release anyway. So you don't
> need to take any action right now, I'll let you know when I'm done with
> this.

Fixed in rev. 967afe5f7d7c. Bjoern, please let me know whether it works
for you now; the -Wl,--no-as-needed option shouldn't be needed any more.
This will be in pure-audio-0.3 when it comes out (real soon now).

The only other affected modules were those in pure-gtk. In that case I
simply disabled LDFLAGS altogether, as the linkage options for the GTK
libraries are determined automatically using pkg-config anyway. I think
that this is the most sensible way to handle this case, as these modules
are generated automatically and in fact they are mostly just empty
shells pulling in the required GTK libraries.

Bjoern Lindig

unread,
Mar 31, 2011, 10:11:25 AM3/31/11
to pure...@googlegroups.com
Hi Albert,

terrific work. Everythings fine with rev 5ba4729270d2. With version 0.46
I recognized a problem with "using glib" - just in case sb
encounters a problem with this version and glib. I tested ffi, gtk,
audio and midi so far and everything seems to be allright.

Many thanks!

Bjoern

On Wed, Mar 30, 2011 at 11:26:58PM +0200, Albert Graef wrote:
>
> Fixed in rev. 967afe5f7d7c. Bjoern, please let me know whether it works
> for you now; the -Wl,--no-as-needed option shouldn't be needed any more.
> This will be in pure-audio-0.3 when it comes out (real soon now).
>
> The only other affected modules were those in pure-gtk. In that case I
> simply disabled LDFLAGS altogether, as the linkage options for the GTK
> libraries are determined automatically using pkg-config anyway. I think
> that this is the most sensible way to handle this case, as these modules
> are generated automatically and in fact they are mostly just empty
> shells pulling in the required GTK libraries.
>
> Albert
>
> --
> Dr. Albert Gr"af
> Dept. of Music-Informatics, University of Mainz, Germany
> Email: Dr.G...@t-online.de, a...@muwiinfa.geschichte.uni-mainz.de
> WWW: http://www.musikinformatik.uni-mainz.de/ag
>

Bjoern Lindig

unread,
Feb 14, 2012, 5:31:45 PM2/14/12
to pure...@googlegroups.com
Hi Albert,

sorry to bring this up again: It was fine in Pure 0.47 and with
pure-audio-0.3. But now, with Pure 0.51 and pure-audio-0.4 the error is
there again. Again 'using sndfile' would fail with a number of errors,
as discribed before in this thread. Using the LDFLAGS="$LDFLAFS -Wl,
--no-as-needed" solves the problem.

Actually, I can live with this, but I'm curious what happened to the
nice sollution with fake dependencies? Did they get lost somewhere or
did they cause problems elsewhere?

Best,

Bjoern

Albert Graef

unread,
Feb 15, 2012, 2:44:23 AM2/15/12
to pure...@googlegroups.com
On 02/14/2012 11:31 PM, Bjoern Lindig wrote:
> sorry to bring this up again: It was fine in Pure 0.47 and with
> pure-audio-0.3. But now, with Pure 0.51 and pure-audio-0.4 the error is
> there again. Again 'using sndfile' would fail with a number of errors,
> as discribed before in this thread. Using the LDFLAGS="$LDFLAFS -Wl,
> --no-as-needed" solves the problem.

Yes, I can reproduce this.

> Actually, I can live with this, but I'm curious what happened to the
> nice sollution with fake dependencies? Did they get lost somewhere or
> did they cause problems elsewhere?

No, I didn't change any of that, it's just that gcc got better in
optimizing away seemingly redundant code. ;-) I'll have to see whether I
can find a better workaround. For the time being, you'll have to use
--no-as-needed.

Bjoern Lindig

unread,
Feb 15, 2012, 6:38:17 AM2/15/12
to pure...@googlegroups.com
> No, I didn't change any of that, it's just that gcc got better in
> optimizing away seemingly redundant code. ;-) I'll have to see
> whether I can find a better workaround. For the time being, you'll
> have to use --no-as-needed.

Well, putting the LDFLAGS into archlinux PKGBUILD script works fine. I
thinks for now it is a proper solution. As soon as I have a little
spare time I will update the pure packages on AUR. Might be at the end
of the week. I'll post it to this list, so that you can announce it on
the website, if you wish.

Best, Bjoern

Albert Graef

unread,
Feb 16, 2012, 4:22:05 AM2/16/12
to pure...@googlegroups.com
On 02/15/2012 12:38 PM, Bjoern Lindig wrote:
> Well, putting the LDFLAGS into archlinux PKGBUILD script works fine. I
> thinks for now it is a proper solution. As soon as I have a little
> spare time I will update the pure packages on AUR. Might be at the end
> of the week.

If you wait a few days then I might already have a solution for this
issue. I'll surely take a look at it over the weekend, or maybe even
tomorrow.

> I'll post it to this list, so that you can announce it on
> the website, if you wish.

That would be great! In fact, we already have an entry for Arch on the
homepage, but it appears to link to outdated packages.

Talking about Arch, I recall that in our private conversation you
mentioned the possibility to put together some kind of live-cd or
bootable USB key with a customized Arch on it. Can you please point me
to some documentation showing how this is done with Arch?

I've been thinking about doing something like this for my students,
which would include Pure, Faust and a selection of other software that
I'm teaching in my courses at the university, so that they can use this
stuff at home without having to install anything. And of course we might
also put together a little Pure-and-friends image which would make it
easy for newcomers to get their feet wet with Pure and try the various
addon modules without having to compile stuff themselves.

I'm considering Ubuntu's remastersys for that purpose, but I think that
Arch's lightweight approach might lend itself more to a stripped-down
selection of packages which includes exactly the things that I need.

Bjoern Lindig

unread,
Feb 16, 2012, 7:45:57 AM2/16/12
to pure...@googlegroups.com
On Thu, 16 Feb 2012 10:22:05 +0100
Albert Graef <Dr.G...@t-online.de> wrote:

> On 02/15/2012 12:38 PM, Bjoern Lindig wrote:
> > Well, putting the LDFLAGS into archlinux PKGBUILD script works
> > fine. I thinks for now it is a proper solution. As soon as I have a
> > little spare time I will update the pure packages on AUR. Might be
> > at the end of the week.
>
> If you wait a few days then I might already have a solution for this
> issue. I'll surely take a look at it over the weekend, or maybe even
> tomorrow.
>
> > I'll post it to this list, so that you can announce it on
> > the website, if you wish.
>
> That would be great! In fact, we already have an entry for Arch on
> the homepage, but it appears to link to outdated packages.
>
> Talking about Arch, I recall that in our private conversation you
> mentioned the possibility to put together some kind of live-cd or
> bootable USB key with a customized Arch on it. Can you please point
> me to some documentation showing how this is done with Arch?

Here is a article that makes it realy easy to install arch anywhere you
want using an existing Linux of any distribution that allows installing
pacman, archs pachage manegement system.

https://wiki.archlinux.org/index.php/Install_from_Existing_Linux

Once you made the configuration for your System you can simply copy it
wherever you want. This is the method I used so far.

Alternatively you can make your own iso-files, if you prefere to have a
fixed system. This is also quite easy, using the archiso scripts:

https://wiki.archlinux.org/index.php/Archiso

I'm did not test this, but it should be quite easy to build your own
iso file from an existing arch installation.

Hope that is enough to convince you of the simplicity arch offers for
this kind of stuff. If not, you can look arround on the wiki. It offers
a bunch of articles that help configuring your system. If you would
like to have recommendations for lightwight system tools like lxde as
desktop environment, I can give you the list of packages that I use for
my usb-system.

Best,

Bjoern

Albert Graef

unread,
Feb 16, 2012, 9:43:43 PM2/16/12
to pure...@googlegroups.com
On 02/16/2012 10:22 AM, Albert Graef wrote:
> On 02/15/2012 12:38 PM, Bjoern Lindig wrote:
>> Well, putting the LDFLAGS into archlinux PKGBUILD script works fine. I
>> thinks for now it is a proper solution. As soon as I have a little
>> spare time I will update the pure packages on AUR. Might be at the end
>> of the week.
>
> If you wait a few days then I might already have a solution for this
> issue. I'll surely take a look at it over the weekend, or maybe even
> tomorrow.

This should be fixed in rev. 316069d13af8. Bjoern, please let me know if
this revision works for you, then I'll release it as pure-audio 0.5.

Albert Graef

unread,
Feb 17, 2012, 3:54:07 PM2/17/12
to pure...@googlegroups.com
On 02/16/2012 01:45 PM, Bjoern Lindig wrote:
> Here is a article that makes it realy easy to install arch anywhere you
> want using an existing Linux of any distribution that allows installing
> pacman, archs pachage manegement system.

Hi Bjoern, thanks a lot for the pointers, I'll give that a try over the
semester holidays.

> I can give you the list of packages that I use for my usb-system.

That would be very helpful! Can you can send it to my private mail, please?

Thanks,

Reply all
Reply to author
Forward
0 new messages