Csound Csound-dev Csound-tekno Search About

a text formatting/Executor question

Date1997-04-24 14:00
FromDave Phillips
Subjecta text formatting/Executor question
I'm using the the Mac CornBucket score generator via Linux Executor: it
works okay, but the formatting is bad. Here's what I get:

  f1 0 8192 10 1^Mi1 0.000000 0.000100 10200.301758 50.250000 0.500000
0.546584^Mi1   0.001000 0.000096 9985.474609 50.348255 0.499969
0.543260^M
  [etc. for a gazillion lines all run together like that]

I've written a little shell script to remove the control characters, but
can anyone tell me how I can automatically reformat the score so that
the lines are arranged properly ? Btw, I don't have Perl, so please
point me to something I could use within bash (or C or Tcl). I'm using
Linux.

Executor can run a number of interesting Mac music/sound apps. Anyone
out there using the full-blown version ? I'm using the demo, thinking
about purchasing the unlocked package. (Unless someone's hacked the time
limit ?)

== Dave Phillips

   http://www.bright.net/~dlphilp/index.html



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa25755;
          24 Apr 97 15:32 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa16451;
          24 Apr 97 15:32 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 15:32:02 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (PAA14940);
          Thu, 24 Apr 1997 15:14:39 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 15:06:45 +0100
Received: from indy1.calarts.edu [156.3.140.68] by hermes via ESMTP (PAA14930);
          Thu, 24 Apr 1997 15:14:25 +0100
Received: from [156.3.140.235] by indy1.calarts.edu 
          via SMTP (951211.SGI.8.6.12.PATCH1042/930416.SGI)	 id HAA00683;
          Thu, 24 Apr 1997 07:05:16 -0700
Message-Id: <199704241405.HAA00683@indy1.calarts.edu>
Subject: Re: a text formatting/Executor question
Date: Thu, 24 Apr 97 07:06:09 -0700
X-Mailer: Claris Emailer 1.1
From: Tom Erbe 
To: Dave Phillips , csound 
Mime-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

>I'm using the the Mac CornBucket score generator via Linux Executor: it
>works okay, but the formatting is bad. Here's what I get:
>
>  f1 0 8192 10 1^Mi1 0.000000 0.000100 10200.301758 50.250000 0.500000
>0.546584^Mi1   0.001000 0.000096 9985.474609 50.348255 0.499969
>0.543260^M
>  [etc. for a gazillion lines all run together like that]
>

This is a problem with Mac/Unix line feed incompatibility. You can fix it 
with BBEdit on the Mac side (open the file, "Save As...", select 
"Options...",
select "Line Breaks->Unix",save). You could also probably fix this with 
sed
on the Unix side. It has been a while since I have had to use sed to do 
this, 
can anyone suggest the proper invocation to convert Mac line-feeds to 
Unix 
line-feeds?

tom erbe
computer music and new media
california institute of the arts
valencia, ca 91355

email: tre@indy1.calarts.edu
URL: http://music.calarts.edu/~tre




Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa25777;
          24 Apr 97 15:52 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa16752;
          24 Apr 97 15:51 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 15:51:08 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (PAA16105);
          Thu, 24 Apr 1997 15:19:54 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 15:19:42 +0100
Received: from empire.is.com [204.120.8.200] by hermes via ESMTP (PAA16072);
          Thu, 24 Apr 1997 15:19:36 +0100
Received: from mspboss.is.com by empire.is.com; Thu, 24 Apr 1997 09:19:24 -0500
Received: from duke.is.com by mspboss.is.com 
          with SMTP (8.6.12/IS-Mailhost-1.0.1/plex_net33)	id JAA05520;
          Thu, 24 Apr 1997 09:19:24 -0500
Message-Id: <199704241419.JAA05520@mspboss.is.com>
Received: by duke.is.com (NX5.67f2/NX3.0X)	id AA06208;
          Thu, 24 Apr 97 09:19:23 -0500
Mime-Version: 1.0 (NeXT Mail 3.3 v118.2)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
In-Reply-To: <199704241405.HAA00683@indy1.calarts.edu>
X-Nextstep-Mailer: Mail 3.3 (Enhance 1.3)
Original-Received:  by NeXT.Mailer (1.118.2)
PP-warning: Illegal Received field on preceding line
From: Michael Pelz-Sherman 
Date: Thu, 24 Apr 97 09:19:21 -0500
To: Tom Erbe 
Subject: Re: a text formatting/Executor question
Cc: Dave Phillips , csound 
References: <199704241405.HAA00683@indy1.calarts.edu>
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk 

> can anyone suggest the proper invocation to convert Mac
> line-feeds to  Unix  line-feeds?

perl is actually better for this sort of thing. For example, the following

perl -pi.bak -e 's/\r/\n/g' [files]

...will replace all Mac-friendly text files with Unix-friendly versions in-place, leaving backup =
copies of the Mac versions named [file].bak. You can use wildcards in [files].

---
Michael Pelz-Sherman | "This thing you call 'language'...
mps@is.com           | you rely on it for so much...
UCSD Music Dept.     | and yet, are any among you really its master?"
PhD Candidate        | Spock/Kolos,
Software Engineer,   | Star Trek episode #62,
Integrity Solutions  | "Is There in Truth No Beauty?"
NeXTMail OK!         | written by Jean Lisette Aroeste

When you're swimmin' in the creek
And an eel bites your cheek
That's a moray!              -- Fabulous Furry Freak Brothers=



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa25846;
          24 Apr 97 16:08 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa17185;
          24 Apr 97 16:08 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 16:07:15 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (QAA19141);
          Thu, 24 Apr 1997 16:02:37 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 15:54:45 +0100
Received: from hplb.hpl.hp.com [15.255.59.2] by hermes via ESMTP (PAA19125);
          Thu, 24 Apr 1997 15:54:44 +0100
Received: from hpbidrd1.bbn.hp.com by hplb.hpl.hp.com;
          Thu, 24 Apr 1997 15:54:50 +0100
Received: from bidra168.bbn.hp.com. (bidra168.bbn.hp.com) 
          by hpbidrd1.bbn.hp.com with ESMTP	(1.37.109.16/15.5+ECS 3.3) 
          id AA250873703; Thu, 24 Apr 1997 15:55:04 +0100
Received: by bidra168.bbn.hp.com.; Thu, 24 Apr 1997 16:52:46 +0200
Message-Id: <199704241452.AA023053566@bidra168.bbn.hp.com.>
Subject: Re: a text formatting/Executor question
To: tre@indy1.calarts.edu
Date: Thu, 24 Apr 1997 16:52:45 METDST
Cc: dlphilp@mail.bright.net, csound@maths.ex.ac.uk
In-Reply-To: <199704241405.HAA00683@indy1.calarts.edu>; from "Tom Erbe" at Apr 24, 97 7:06 am
Organization: Hewlett-Packard GmbH
From: Jens Kilian 
Reply-To: Jens_Kilian@hpbidrd.bbn.hp.com
X-Mailer: Elm [revision: 112.2]
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk 

> can anyone suggest the proper invocation to convert Mac line-feeds to 
> Unix 
> line-feeds?

        tr '\015' '\012' < foo > bar

Greetings,

        Jens.
--
mailto:jjk@acm.org                  phone:+49-7031-14-7698 (HP TELNET 778-7698)
                                      fax:+49-7031-14-7351
PGP:       06 04 1C 35 7B DC 1F 26  As the air to a bird, or the sea to a fish,
0x555DA8B5 BB A2 F0 66 77 75 E1 08  so is contempt to the contemptible. [Blake]



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa25885;
          24 Apr 97 16:21 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa17427;
          24 Apr 97 16:20 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 16:20:04 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (PAA18491);
          Thu, 24 Apr 1997 15:48:39 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 15:48:33 +0100
Received: from [205.216.133.3] by hermes via ESMTP (PAA18091);
          Thu, 24 Apr 1997 15:43:53 +0100
Received: from sinewave (port017.vta.fishnet.net [205.216.133.166]) 
          by big.fishnet.net (8.7.5/8.6.9) with SMTP id GAA26509;
          Thu, 24 Apr 1997 06:48:30 -0700
Message-Id: <335F6409.4514AAF2@rcsreg.com>
Date: Thu, 24 Apr 1997 06:45:45 -0700
From: Toby 
X-Mailer: Mozilla 3.01Gold (X11; I; Linux 2.0.27 i486)
Mime-Version: 1.0
To: Dave Phillips 
Cc: csound@maths.ex.ac.uk
Subject: Re: a text formatting/Executor question
References: <335F595E.45805BB7@bright.net>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Dave Phillips wrote:
> Here's what I get:
>   f1 0 8192 10 1^Mi1 0.000000 0.000100 10200.301758 50.250000 0.500000
> 0.546584^Mi1   0.001000 0.000096 9985.474609 50.348255 0.499969
> 0.543260^M
>   [etc. for a gazillion lines all run together like that]

> can anyone tell me how I can automatically reformat the score so that
> the lines are arranged properly ? Btw, I don't have Perl, so please
> point me to something I could use within bash (or C or Tcl). I'm using
> Linux.


As I remember, text is output this way on the
following OS's:

UNIX LF
MAC  CR
DOS  CR/LF

Try this as a filter for your score output:

#include 

main()
{
char c;
        while( (c = getc(stdin)) != EOF){
                if(c == 13)
                        putc( '\n', stdout);
                else
                        putc( c, stdout);
        }
}

Save it to a file called 'chop.c' and do

make chop

Then do

chop < bogus > cool

I haven't tested this, but it looks to me
as though it should convert Mac text to 
Unix text.

Toby

	-There otta be a law-


P.S.  This would be the Dos to Unix Code:
(There could be no conceivable need for
 conversion from Unix to one of the other
 OS's --  Whoa, just kidding) 

#include 

main()
{
char c;
        while( (c = getc(stdin)) != EOF){
                if(c != 13)
                	putc( c, stdout);
        }
}


~
~
~



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa25891;
          24 Apr 97 16:21 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa17432;
          24 Apr 97 16:20 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 16:20:23 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (PAA18829);
          Thu, 24 Apr 1997 15:51:53 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 15:51:47 +0100
Received: from netserve.lasc.lockheed.com [134.5.45.28] by hermes 
          via ESMTP (PAA18786); Thu, 24 Apr 1997 15:51:19 +0100
Received: from gms0.mar.lmco.com by netserve.mar.lmco.com 
          with SMTP	(1.39.111.2/16.2) id AA026222489;
          Thu, 24 Apr 1997 10:34:49 -0400
Received: from gms5.mar.lmco.com 
          by gms0.mar.lmco.com (5.x/SMI-SVR4)	id AA10725;
          Thu, 24 Apr 1997 10:36:47 -0400
Received: by gms5.mar.lmco.com (SMI-8.6/SMI-SVR4)	id KAA12709;
          Thu, 24 Apr 1997 10:36:36 -0400
Date: Thu, 24 Apr 1997 10:36:36 -0400
From: George Campbell 
Message-Id: <199704241436.KAA12709@gms5.mar.lmco.com>
To: tre@indy1.calarts.edu, dlphilp@mail.bright.net
Subject: Re: a text formatting/Executor question
Cc: csound@maths.ex.ac.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Md5: a75ageT46jVu7c0mnBxErg==
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

> From owner-csound-outgoing@maths.exeter.ac.uk Thu Apr 24 10:23 EDT 1997
> Subject: Re: a text formatting/Executor question
> Date: Thu, 24 Apr 97 07:06:09 -0700
> From: Tom Erbe 
> To: "Dave Phillips" , 
> 
> >I'm using the the Mac CornBucket score generator via Linux Executor: it
> >works okay, but the formatting is bad. Here's what I get:
> >
> >  f1 0 8192 10 1^Mi1 0.000000 0.000100 10200.301758 50.250000 0.500000
> >0.546584^Mi1   0.001000 0.000096 9985.474609 50.348255 0.499969
> >0.543260^M
> >  [etc. for a gazillion lines all run together like that]
> 
> This is a problem with Mac/Unix line feed incompatibility. You can fix
> it with BBEdit on the Mac side (open the file, "Save As...", select 
> "Options...", select "Line Breaks->Unix",save). You could also probably
> fix this with sed on the Unix side. It has been a while since I have
> had to use sed to do this, can anyone suggest the proper invocation
> to convert Mac line-feeds to Unix line-feeds?
> 
> tom erbe

  I don't know about Mac line ending conventions, but there are a couple
  of utilities on my UNIX (Solaris 2.5) that can be used to convert
  text files from UNIX to DOS and vice versa. They're call "unix2dos"
  and "dos2unix". The "unix2dos" utility adds a carriage return before
  line feeds, and "dos2unix" strips out carriage returns, leaving just
  the line feeds, which is what UNIX expects as a line terminator. The
  "^M"s in that excerpt from the file are carriage returns. Presumably,
  the "dos2unix" utility would also work on MAC files.
  
  George



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa26892;
          24 Apr 97 23:11 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa22672;
          24 Apr 97 23:10 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 23:10:18 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (XAA12809);
          Thu, 24 Apr 1997 23:11:46 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 23:03:55 +0100
Received: from sparticus.bright.net [205.212.123.14] by hermes 
          via ESMTP (XAA12806); Thu, 24 Apr 1997 23:11:38 +0100
Received: from brutus (root@find4-cs-6.dial.bright.net [205.212.145.186]) 
          by mail.bright.net (8.8.5/8.8.5/FNG) with SMTP id RAA10536;
          Thu, 24 Apr 1997 17:57:12 -0400 (EDT)
Message-Id: <335FD83D.3127A18@bright.net>
Date: Thu, 24 Apr 1997 18:01:33 -0400
From: Dave Phillips 
X-Mailer: Mozilla 3.0 (X11; I; Linux 2.0.29 i486)
Mime-Version: 1.0
To: Jens_Kilian@hpbidrd.bbn.hp.com
Cc: csound@maths.ex.ac.uk
Subject: Re: a text formatting/Executor question
References: <199704241452.AA023053566@bidra168.bbn.hp.com.>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Jens Kilian wrote:
 
> > can anyone suggest the proper invocation to convert Mac line-feeds to
> > Unix
> > line-feeds?
> 
>         tr '\015' '\012' < foo > bar

That did it. Thanks, Jens, and thanks to all others who responded !

== Dave Phillips

   http://www.bright.net/~dlphilp/index.html



Received: from stork2.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa26978;
          24 Apr 97 23:58 BST
Received: from goggins.bath.ac.uk by stork.maths.Bath.AC.UK id aa23481;
          24 Apr 97 23:57 BST
Received: from hermes.ex.ac.uk by goggins.bath.ac.uk with SMTP (PP);
          Thu, 24 Apr 1997 23:57:28 +0100
Received: from noether [144.173.8.10] by hermes via SMTP (XAA14497);
          Thu, 24 Apr 1997 23:51:19 +0100
Received: from hermes.ex.ac.uk by maths.exeter.ac.uk;
          Thu, 24 Apr 97 23:51:14 +0100
Received: from dfw-ix9.ix.netcom.com [206.214.98.9] by hermes 
          via ESMTP (XAA14491); Thu, 24 Apr 1997 23:51:12 +0100
Received: (from smap@localhost)          
          by dfw-ix9.ix.netcom.com (8.8.4/8.8.4)	  id RAA11336 
          for ;
          Thu, 24 Apr 1997 17:50:45 -0500 (CDT)
Received: from grn-sc1-15.ix.netcom.com(205.184.144.47) 
          by dfw-ix9.ix.netcom.com via smap (V1.3)	id sma010765;
          Thu Apr 24 17:49:46 1997
Message-Id: <335FAB21.436D552E@ix.netcom.com>
Date: Thu, 24 Apr 1997 14:49:05 -0400
From: Tomy Hudson 
Organization: Software Arts and Consulting
X-Mailer: Mozilla 3.01Gold (X11; I; Linux 2.0.18 i486)
Mime-Version: 1.0
To: csound@maths.ex.ac.uk
Subject: Re: a text formatting/Executor question
References: <199704241452.AA023053566@bidra168.bbn.hp.com.>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Jens wrote

> tr '\015' '\012' < foo > bar

There's a saying among Perl programmers "TIMTOWTDI" (pronounced "Tim
Toady"), 
"There Is More Than One Way To Do It", but it's hard for a Unix geek
like myself
to not find beauty in the simplest and most terse. Thanks Jens for
pulling
out another oft' forgotten but useful "blade" from the Swiss Army Knife
of
operating systems. BTW, you can save typing four characters by

tr '\r' '\n' < foo > bar

Dave, you mentioned running music apps under Executor on Linux. What Mac
apps
have you been successful at running? 

Tomy