update call at mget(i) and mput(i) with 'l' instead of 'i' 24/12624/2
Antoine ELIAS [Fri, 20 Sep 2013 13:53:32 +0000 (15:53 +0200)]
Change-Id: Id0f3b31f1a1959274ddc501394c5b8eee9a69d3a

scilab/modules/compatibility_functions/macros/mtlb_fread.sci
scilab/modules/compatibility_functions/macros/mtlb_fwrite.sci
scilab/modules/functions/macros/bytecode.sci
scilab/modules/helptools/data/configuration/scilab_macros.txt
scilab/modules/matio/macros/ReadmiMatrix.sci [deleted file]
scilab/modules/matio/macros/WritemiMatrix.sci [deleted file]
scilab/modules/sound/macros/auread.sci
scilab/modules/sound/macros/auwrite.sci
scilab/modules/sound/macros/savewave.sci
scilab/modules/sound/macros/wavread.sci

index c825009..f315a98 100644 (file)
@@ -13,21 +13,21 @@ function [a, count]=mtlb_fread(fid,sz,prec)
     prectbl=["c"  "char"    "char"
     "?"  "schar"   "signed char"
     "s"  "short"   "short"
-    "l"  "int"     "int"
+    "i"  "int"     "int"
     "l"  "long"    "long"
     "f"  "float"   "float"
     "d"  "double"  "double"
     "uc" "uchar"   "unsigned char"
     "us" "ushort"  "unsigned short"
-    "ul" "uint"    "unsigned int"
+    "ui" "uint"    "unsigned int"
     "ul" "ulong"   "unsigned long"
     "c"  "char"    "char*1"
     "f"  "float32" "real*4"
     "d"  "float64" "real*8"
     "c"  "int8"    "integer*1"
     "s"  "int16"   "integer*2"
-    "l"  "int32"   "integer*4"
-    "?"  ""        "integer*8"
+    "i"  "int32"   "integer*4"
+    "l"  ""        "integer*8"
     "?"  "intN"    ""
     "?"  "uintN"   ""         ]
 
@@ -43,7 +43,7 @@ function [a, count]=mtlb_fread(fid,sz,prec)
     if l==[] then
         error(msprintf(gettext("%s: The format ''%s'' is unknown.\n"), "mtlb_fread", prec))
     end
-    Prec=prectbl(l,1)
+    Prec=prectbl(l(1),1)
     if Prec=="?" then
         error(msprintf(gettext("%s: The format ''%s'' is not yet handled.\n"), "mtlb_fread", prec))
     end
index e6ccb09..00108a1 100644 (file)
@@ -14,21 +14,21 @@ function count=mtlb_fwrite(fid,a,prec)
     prectbl=["c"  "char"    "char"
     "?"  "schar"   "signed char"
     "s"  "short"   "short"
-    "l"  "int"     "int"
+    "i"  "int"     "int"
     "l"  "long"    "long"
     "f"  "float"   "float"
     "d"  "double"  "double"
     "uc" "uchar"   "unsigned char"
     "us" "ushort"  "unsigned short"
-    "ul" "uint"    "unsigned int"
+    "ui" "uint"    "unsigned int"
     "ul" "ulong"   "unsigned long"
     "c"  "char"    "char*1"
     "f"  "float32" "real*4"
     "d"  "float64" "real*8"
     "c"  "int8"    "integer*1"
     "s"  "int16"   "integer*2"
-    "l"  "int32"   "integer*4"
-    "?"  ""        "integer*8"
+    "i"  "int32"   "integer*4"
+    "l"  ""        "integer*8"
     "?"  "intN"    ""
     "?"  "uintN"   ""         ]
 
index 04652c2..2ed382f 100644 (file)
@@ -14,8 +14,8 @@ function x=bytecode(f)
     if type(f)==8 then //bytecode to function
         u=mopen(TMPDIR+"/%fun.bin","wb");
         name_x=[673720353 673720360 673720360 673720360 673720360 673720360]
-        mput(int32([name_x  13]),"l",u)
-        mput(f,"l",u)
+        mput(int32([name_x  13]),"i",u)
+        mput(f,"i",u)
         mclose(u)
         load(TMPDIR+"/%fun.bin")
     elseif type(f)==13 then //function to bytecode
index 3e1b475..3c3dc0c 100644 (file)
@@ -798,13 +798,11 @@ NDcost
 OS_Version
 PlotSparse
 ReadHBSparse
-ReadmiMatrix
 ResetFigureDDM
 Sfgrayplot
 Sgrayplot
 TCL_CreateSlave
 TitleLabel
-WritemiMatrix
 abcd
 abinv
 accept_func_default
diff --git a/scilab/modules/matio/macros/ReadmiMatrix.sci b/scilab/modules/matio/macros/ReadmiMatrix.sci
deleted file mode 100644 (file)
index 0c2bd9f..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
-// Copyright (C) ???? - INRIA - Serge STEER
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function [value,ArrayName]=ReadmiMatrix(fd)
-    // Read a variable in a Matlab binary file
-    // This function has been developed following the 'MAT-File Format' description:
-    // www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
-    // Copyright INRIA
-    // Authors: SS, VC
-
-    [DataType,NumberOfBytes,Compressed]=ReadTag(fd);
-    if meof(fd) then value=[],ArrayName="",return,end
-    if DataType<>miMatrix then
-        error(msprintf(gettext("Found Datatype=%d, expecting %d."),DataType,miMatrix));
-    end
-    if NumberOfBytes==0 then value=[],return,end
-    [Flags,Class,NnzMax]=ReadArrayFlags(fd);
-    DimensionArray=ReadDimensionArray(fd);
-    ArrayName=ReadArrayName(fd)
-    select Class
-    case DoubleClass
-        value=double(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case SingleClass
-        value=ReadSimpleElement(fd,prod(DimensionArray),Class)
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Int8Class
-        value=int8(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Uint8Class
-        value=uint8(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Int16Class
-        value=int16(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Uint16Class
-        value=uint16(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Int32Class
-        value=int32(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case Uint32Class
-        value=uint32(ReadSimpleElement(fd,prod(DimensionArray),Class))
-        if Flags(1) then
-            value=double(value)+%i*double(ReadSimpleElement(fd,prod(DimensionArray)))
-        end
-        value=matrix(value,DimensionArray)
-    case CellClass
-
-        entries=list()
-        for k=1:prod(DimensionArray)
-            entries(k)=ReadmiMatrix(fd)
-        end
-        value=mlist(["ce","dims","entries"],int32(DimensionArray),entries)
-    case CharClass
-        value=matrix(ReadSimpleElement(fd,prod(DimensionArray)),DimensionArray(1),-1)
-        t=[];for v=value',t=[t;stripblanks(ascii(double(v)))];end
-        value=t
-    case StructClass
-        FieldNameLength=double(ReadSimpleElement(fd,1))
-        FieldNames=matrix(ReadSimpleElement(fd),FieldNameLength,-1)
-        NumberOfFields=size(FieldNames,2)
-        Fnams=[];Fields=list();
-        for k=1:NumberOfFields
-            l=find(FieldNames(:,k)==0,1)-1;
-            Fnams=[Fnams,stripblanks(ascii(double(FieldNames(1:l,k))))];
-            Fields(k)=list();
-        end
-
-        if prod(DimensionArray)==1 then
-            for k=1:NumberOfFields
-                Fields(k)=ReadmiMatrix(fd);
-            end
-        else
-            Fk=list();for i=1:size(DimensionArray,"*"),Fk(i)=[];end
-            for k=1:NumberOfFields,Fields(k)=Fk,end
-            for i=1:prod(DimensionArray)
-                for k=1:NumberOfFields
-                    Fields(k)(i)=ReadmiMatrix(fd);
-                end
-            end
-        end
-        //Form Scilab representation
-        value=mlist(["st" "dims" Fnams],int32(DimensionArray),Fields(:))
-    case ObjectClass
-        ClassName=stripblanks(ascii(double(ReadSimpleElement(fd))))
-        FieldNameLength=double(ReadSimpleElement(fd,1))
-        FieldNames=matrix(ReadSimpleElement(fd),FieldNameLength,-1)
-        NumberOfFields=size(FieldNames,2)
-        Fields=list();Fnams=[]
-        for k=1:NumberOfFields
-            l=find(FieldNames(:,k)==0,1)-1
-            Fnams=[Fnams,stripblanks(ascii(double(FieldNames(1:l,k))))]
-            Fields(k)=ReadmiMatrix(fd)
-        end
-        //Form Scilab representation
-        value=tlist([ClassName, Fnams],Fields(:))
-        select ClassName
-        case "inline" then
-            value=Object2Inline(value)
-        case "ss" then
-            value=Object2SS(value)
-        case "tf" then
-            value=Object2tf(value)
-        end
-    case SparseClass then
-        RowIndex=double(ReadSimpleElement(fd,NnzMax))
-        ColumnIndex=double(ReadSimpleElement(fd,DimensionArray(2)+1))
-        value=double(ReadSimpleElement(fd))
-        if Flags(1) then
-            value=value+%i*double(ReadSimpleElement(fd))
-        end
-
-        //Form Scilab representation
-        ptr=ColumnIndex(2:$)-ColumnIndex(1:$-1);
-        col=[];cc=1;
-        for ic=1:size(ptr,"*")
-            col=[col;cc(ones(ptr(ic),1))];cc=cc+1;
-        end
-        //in some cases the initial value of ne is  bigger than necessary
-        ne=min(size(RowIndex,"*"),size(col,"*"));
-        RowIndex=RowIndex(1:ne);col=col(1:ne);
-        if RowIndex<>[] then RowIndex=RowIndex(:)+1,end
-        value=sparse([col(:),RowIndex],value(:),DimensionArray([2 1])).'
-    else
-        error(gettext("Unknown Class."));
-    end
-endfunction
-
-function [DataType,NumberOfBytes,Compressed]=ReadTag(fd)
-    //--TAG
-    //Copyright INRIA
-    //Author Serge Steer
-    p1=mtell(fd)
-
-    t=mget(2,md_s,fd);
-    if t==[] then //EOF
-        DataType=0;NumberOfBytes=0,Compressed=%f
-    else
-        if endian=="l" then t=t([2 1]),end
-        Compressed=t(1)<>0;
-        if Compressed then // compressed data element format
-            NumberOfBytes=t(1)
-            DataType=t(2)
-        else
-            mseek(p1,fd)
-            DataType=mget(1,md_i,fd);
-            NumberOfBytes=mget(1,md_i,fd);
-        end
-    end
-endfunction
-
-
-
-function [Flags,Class,NnzMax]=ReadArrayFlags(fd)
-    //Copyright INRIA
-    //Author Serge Steer
-    [DataType,NumberOfBytes,Compressed]=ReadTag(fd)
-    B=mget(4,"uc",fd);
-    if endian=="l" then B=B([4 3 2 1]),end
-    Class=B(4)
-    Flags=byte2bits(B(3));Flags=Flags(4:-1:2)
-    NnzMax=mget(1,md_i,fd)
-endfunction
-
-function dims=ReadDimensionArray(fd)
-    //Copyright INRIA
-    //Author Serge Steer
-    dims=double(ReadSimpleElement(fd))
-endfunction
-
-function ArrayName=ReadArrayName(fd)
-    //Copyright INRIA
-    //Author Serge Steer
-    ArrayName=ascii(double(ReadSimpleElement(fd)))
-endfunction
-
-function value=ReadSimpleElement(fd,NumberOfValues,Class)
-    //Copyright INRIA
-    //Author Serge Steer
-    pse=mtell(fd)
-    [DataType,NumberOfBytes,Compressed]=ReadTag(fd)
-    select DataType
-    case miDOUBLE
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/8,end
-        value=mget(NumberOfValues,md_d,fd)
-    case miSINGLE
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/4,end
-        value=mget(NumberOfValues,md_f,fd)
-    case miINT8
-        if argn(2)==1 then NumberOfValues=NumberOfBytes,end
-        value=mgeti(NumberOfValues,"c",fd)
-    case miUINT8
-        if argn(2)==1 then NumberOfValues=NumberOfBytes,end
-        value=mgeti(NumberOfValues,"uc",fd)
-    case miINT16
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/2,end
-        value=mgeti(NumberOfValues,md_s,fd)
-    case miUINT16
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/2,end
-        value=mget(NumberOfValues,"u"+md_s,fd)
-    case miUINT32
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/4,end
-        value=mgeti(NumberOfValues,"u"+md_i,fd)
-    case miINT32
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/4,end
-        value=mgeti(NumberOfValues,md_i,fd)
-    case miUINT64
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/8,end
-        value=mget(NumberOfValues,"u"+md_l,fd)
-    case miINT64
-        if argn(2)==1 then NumberOfValues=NumberOfBytes/8,end
-        value=mget(NumberOfValues,md_l,fd)
-    case miMatrix
-        mseek(pse,fd)
-        [value,ArrayName]=ReadmiMatrix(fd)
-    else
-        error(msprintf(gettext("Not implemented DataType: %d."),DataType));
-    end
-    padding()
-
-endfunction
-
-
-function padding()
-    // skip padding data
-    //----------------------------------------------
-    //Copyright INRIA
-    //Author Serge Steer
-
-    //data fields are aligned on double words
-    np=modulo(8-modulo(mtell(fd),8),8)
-    if np>0 then mget(np,"uc",fd),end
-endfunction
-
-function showbin(n,pi)
-    //for debugging purpose
-    //----------------------------------------------
-    //Copyright INRIA
-    //Author Serge Steer
-
-    p=mtell(fd)
-    if argn(2)==2 then mseek(pi,fd),end
-    x=string(matrix(mgeti(8*n,"uc",fd),8,-1)')
-    t=emptystr(n,1)+"|"
-    for k=1:4
-        t=t+part(x(:,k),1:max(length(x(:,k)))+1)
-    end
-    t=t+"|"
-    for k=5:8
-        t=t+part(x(:,k),1:max(length(x(:,k)))+1)
-    end
-    t=t+"|"
-    write(%io(2),t,"(a)")
-    mseek(p,fd)
-endfunction
-
-
-function [head,version,swap]=matfile_header(fd)
-    //get the mat file header information
-    //Copyright INRIA
-    //Author Serge Steer
-
-    head=ascii(mget(124,"uc",fd))
-    version=mget(2,"uc",fd)
-    //Magic number endian coding
-    IM_MI=mget(2,"uc",fd);
-    if and(IM_MI==[73,77]) then // little endian file
-        swap="l"
-    elseif and(IM_MI==[77,73]) then // big endian file
-        swap="b"
-    else
-        mclose(fd);
-        // This line has to be mofified according to message in 'loadmatfile' function
-        error(gettext("Invalid level 5 binary MAT-file!."));
-    end
-endfunction
-
-function LoadMatConstants()
-    //set constants. This function should be exec'ed
-    //Copyright INRIA
-    //Author Serge Steer
-
-    miINT8=1
-    miUINT8=2
-    miINT16=3
-    miUINT16=4
-    miINT32=5
-    miUINT32=6
-    miSINGLE=7
-    //
-    miDOUBLE=9
-    //
-    //
-    miINT64=12
-    miUINT64=13
-    miMatrix=14
-
-    CellClass=1
-    StructClass=2
-    ObjectClass=3
-    CharClass=4
-    SparseClass=5
-    DoubleClass=6
-    SingleClass=7
-    Int8Class=8
-    Uint8Class=9
-    Int16Class=10
-    Uint16Class=11
-    Int32Class=12
-    Uint32Class=13
-
-    //--set various reading format
-    md_i="i"+endian;md_d="d"+endian;md_s="s"+endian;md_l="l"+endian;md_f="f"+endian;
-
-endfunction
-
-function value=Object2Inline(value)
-    //convert inline object to scilab function
-    //Copyright INRIA
-    //Author Serge Steer
-
-    deff("ans=value("+strcat(stripblanks(value.args),",")+")",value.expr,"n")
-    comp(value,1);code=macr2lst(value)
-    load SCI/modules/m2sci/macros/lib
-    killed=[];quote="''";dquote="""";batch=%f
-    [value,trad]=m2sci(code,"value",%f,%f)
-    value($)="endfunction"
-    //define the final version
-    execstr(value)
-endfunction
-
-function res=Object2SS(res)
-    //convert ss object to scilab 'lss'
-    //Copyright INRIA
-    //Author Serge Steer
-    A=res.a;if type(A)==17 then A=A.entries(1),end
-    B=res.b;if type(B)==17 then B=B.entries(1),end
-    C=res.c;if type(C)==17 then C=C.entries(1),end
-    D=res.d;if type(D)==17 then D=D.entries(1),end
-    E=res.e;if type(E)==17 then E=E.entries(1),end
-    st_nam=res.StateName
-    props=res.lti
-    dt=props.Ts;if dt==0 then dt="c",end
-    res=syslin(dt,A,B,C,D)
-    res($+1)=props
-    res(1)($+1)="Properties"
-endfunction
-
-function res=Object2tf(res)
-    //convert tf object to scilab 'r'
-    //Copyright INRIA
-    //Author Serge Steer
-    v=res.Variable
-    dims=double(res.num.dims) //res.num.dims may be an integer array
-    props=res.lti
-    num=[];den=[];
-    for k=1:prod(dims)
-        num=[num;poly(res.num.entries(k)($:-1:1),v,"c")];
-        den=[den;poly(res.den.entries(k)($:-1:1),v,"c")];
-    end
-    num=matrix(num,dims)
-    den=matrix(den,dims)
-    dt=props.Ts;if dt==0 then dt="c",end
-    res=syslin(dt,num,den)
-    res(1)($+1)="Properties"
-    res($+1)=props
-endfunction
-
-function fd=open_matfile(fil)
-    //Copyright INRIA
-    //Author Serge Steer
-    fil=stripblanks(fil)
-    fd=mopen(fil,"rb",0)
-endfunction
-
-function b=int2bytes(i)
-    //Copyright INRIA
-    //Author Serge Steer
-    it=inttype(i);it1=modulo(it,10)
-    if it1==1 then
-        b=i(:)
-    else
-        s=iconvert(2^(4*(0:it1-1)),it)
-        d=i;b=s(:);
-        for k=1:it1
-            x=s(it1-k+1);b(k) = d/x; d = d-b(k)*x;
-        end
-    end
-endfunction
-
-function b=byte2bits(i)
-    //Copyright INRIA
-    //Author Serge Steer
-    b=(iconvert(i,11)&iconvert(2^(0:3),11))<>uint8(0)
-endfunction
-
-function I=columnfirstorder(d)
-    nd=size(d,"*")
-    if nd==2 then
-        I=matrix(matrix(1:prod(d),d)',1,-1)
-    else
-        dd=prod(d(3:$))
-        I1=matrix(1:prod(d),d(1),d(2),dd)
-        I=[]
-        for k=1:dd
-            I=[I matrix(I1(:,:,k)',1,-1)]
-        end
-    end
-endfunction
diff --git a/scilab/modules/matio/macros/WritemiMatrix.sci b/scilab/modules/matio/macros/WritemiMatrix.sci
deleted file mode 100644 (file)
index b835b59..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
-// Copyright (C) ???? - INRIA - Serge STEER
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution.  The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-
-function WritemiMatrix(fd,value,ArrayName)
-    // Save variables in a Matlab binary file
-    // This function has been developed following the 'MAT-File Format' description:
-    // www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf
-
-    TagSize=8; // 8 bytes
-    ArrayFlagSize=8; // 8 bytes
-
-    // Position is saved to come back here after writing
-    SavePosBefore=mtell(fd);
-
-    // Save space for TAG
-    WriteEmptyTag(fd);
-
-    // Position is saved to compute number of written bytes
-    NumberOfBytes=mtell(fd);
-
-    // Save space for ARRAY FLAGS
-    WriteEmptyArrayFlags(fd);
-
-    // Compute array dimensions
-    if type(value)==10 then
-        WriteDimensionArray(fd,size(mstr2sci(value)));
-    else
-        WriteDimensionArray(fd,size(value));
-    end
-
-    // Write variable name
-    WriteArrayName(fd,ArrayName);
-
-    Flags=[0 0 0];
-
-    if type(value)==1 then // DOUBLE value
-        value=matrix(value,1,-1);
-        Flags(1)=bool2s(~isreal(value));
-        Class=DoubleClass;
-        NnzMax=0;
-        WriteSimpleElement(fd,real(value),miDOUBLE);
-        if Flags(1) then
-            WriteSimpleElement(fd,imag(value),miDOUBLE);
-        end
-    elseif type(value)==10 then // CHARACTER STRING value
-        if size(value,"*")==1 then
-            value=matrix(ascii(mstr2sci(value)),1,-1);
-            Flags(1)=0;
-            Class=CharClass;
-            NnzMax=0;
-            WriteSimpleElement(fd,value,miUINT16);
-        else
-            warning(gettext("Scilab string matrix saved as Matlab Cell."));
-            sz=size(value);
-            value=matrix(value,1,-1);
-            entries=list()
-            for k=1:size(value,2)
-                entries(k)=value(k);
-            end
-            value=mlist(["ce","dims","entries"],int32(sz),entries)
-            mseek(SavePosBefore,fd);
-            WritemiMatrix(fd,value,ArrayName);
-            return
-        end
-    elseif type(value)==8 then // INTEGER value
-        value=matrix(value,1,-1);
-        Flags(1)=0;
-        NnzMax=0;
-        select typeof(value)
-        case "int8"
-            Class=Int8Class;
-            WriteSimpleElement(fd,value,miINT8);
-        case "uint8"
-            Class=Uint8Class;
-            WriteSimpleElement(fd,value,miUINT8);
-        case "int16"
-            Class=Int16Class;
-            WriteSimpleElement(fd,value,miINT16);
-        case "uint16"
-            Class=Uint16Class;
-            WriteSimpleElement(fd,value,miUINT16);
-        case "int32"
-            Class=Int32Class;
-            WriteSimpleElement(fd,value,miINT32);
-        case "uint32"
-            Class=Uint32Class;
-            WriteSimpleElement(fd,value,miUINT32);
-        else
-            error(msprintf(gettext("Unknown integer type: %s."),typeof(value)));
-        end
-    elseif type(value)==17 then // MLIST used ofr CELLS and STRUCTS
-        Flags(1)=0;
-        NnzMax=0;
-        select typeof(value)
-        case "ce" // CELL
-            Class=CellClass;
-            for k=1:lstsize(value.entries)
-                WritemiMatrix(fd,value(k).entries,"");
-            end
-        case "st" // STRUCT
-            Class=StructClass;
-            Fnams=getfield(1,value);
-            Fnams(1:2)=[];
-            FieldNameLength=32;
-            WriteSimpleElement(fd,FieldNameLength,miINT32);
-
-            NumberOfFields=size(Fnams,2);
-            FieldNames=[]
-            for k=1:NumberOfFields
-                FieldNames=[FieldNames ascii(Fnams(k)) zeros(1,FieldNameLength-length(Fnams(k)))];
-            end
-
-            WriteSimpleElement(fd,FieldNames,miINT8);
-            if prod(size(value))==1 then
-                for k=1:NumberOfFields
-                    WritemiMatrix(fd,value(Fnams(k)),"");
-                end
-            else
-                for i=1:prod(size(value))
-                    for k=1:NumberOfFields
-                        WritemiMatrix(fd,value(i)(Fnams(k)),"");
-                    end
-                end
-            end
-        else
-            error(msprintf(gettext("%s mlist type not yet implemented."),typeof(value)));
-        end
-    elseif or(type(value)==[5,7]) then // SPARSE matrices
-        if type(value)==5 then // Scilab sparse is converted to Matlab sparse
-            value=mtlb_sparse(value);
-        end
-        Class=SparseClass;
-        [ij,v,mn]=spget(value);
-        RowIndex=ij(:,1)-1;
-        col=ij(:,2);
-        NnzMax=length(RowIndex);
-
-        WriteSimpleElement(fd,RowIndex,miINT32);
-
-        ColumnIndex=col(1);
-        for k=1:size(col,"*")-1
-            if col(k)<>col(k+1) then
-                ColumnIndex=[ColumnIndex;col(k+1)]
-            end
-        end
-
-        ptr=0;
-        for k=1:size(ColumnIndex,"*")
-            ptr=[ptr;size(find(col==ColumnIndex(k)),"*")]
-        end
-        ColumnIndex=cumsum(ptr);
-
-        WriteSimpleElement(fd,ColumnIndex,miINT32);
-
-        Flags(1)=bool2s(~isreal(v));
-        WriteSimpleElement(fd,real(v),miDOUBLE);
-        if Flags(1) then
-            WriteSimpleElement(fd,imag(v),miDOUBLE);
-        end
-    else
-        error(msprintf(gettext("%s not yet implemented."),typeof(value)));
-    end
-
-    SavePosAfter=mtell(fd);
-
-    NumberOfBytes=SavePosAfter-NumberOfBytes
-
-    // Update tag
-    WriteTag(fd,miMatrix,NumberOfBytes);
-
-    mseek(SavePosBefore+TagSize+TagSize+ArrayFlagSize,fd);
-
-    // Update array flags
-    WriteArrayFlags(fd,Flags,Class,NnzMax);
-
-    mseek(SavePosAfter,fd);
-endfunction
-
-function fd=open_matfile_wb(fil)
-    // Copyright INRIA
-    // Opens a file in 'w+b' mode
-    // VC
-    fil=stripblanks(fil)
-    fd=mopen(fil,"w+b",0)
-endfunction
-
-function swap=write_matfile_header(fd)
-    // Copyright INRIA
-    // Write the mat file header information
-    // VC
-
-    head=gettext("MATLAB 5.0 MAT-file, Generated by Scilab");
-    head=head+part(" ",1:(124-length(head)));
-    mput(ascii(head),"uc",fd);
-
-    version=[1 0];
-    mput(version,"uc",fd);
-
-    endian_indicator=ascii(["M" "I"]);
-    mput(endian_indicator,"uc",fd);
-
-    // Character are read just after to get endian
-    // Because mput swap automatically bytes
-    // if endian not given when writing
-    mseek(mtell(fd)-2,fd);
-    IM_MI=mget(2,"uc",fd);
-    if and(IM_MI==[73,77]) then // little endian file
-        swap="l"
-    elseif and(IM_MI==[77,73]) then // big endian file
-        swap="b"
-    else
-        error(gettext("Error while writing MI."));
-    end
-    // Following call to mseek is needed under Windows
-    // to set file pointer after reading
-    mseek(0,fd,"cur");
-endfunction
-
-function WriteEmptyTag(fd)
-    // Copyright INRIA
-    // Reserve space for a tag
-    // VC
-
-    for k=1:TagSize
-        mput(0,"uc",fd);
-    end
-endfunction
-
-function WriteEmptyArrayFlags(fd)
-    // Copyright INRIA
-    // Reserve space for an array flag
-    // VC
-
-    for k=1:ArrayFlagSize+TagSize
-        mput(0,"uc",fd);
-    end
-endfunction
-
-function WriteArrayFlags(fd,Flags,Class,NnzMax)
-    // Copyright INRIA
-    // Write an array flag
-    // VC
-
-    WriteTag(fd,miUINT32,ArrayFlagSize);
-
-    mseek(mtell(fd)-ArrayFlagSize,fd);
-
-    Flags=[0 Flags(3:-1:1)];
-
-    B=[0 0 0 0];
-    B(3)=bits2byte(Flags);
-    B(4)=Class;
-    mput(B,"uc",fd);
-
-    mput(NnzMax,md_i,fd);
-endfunction
-
-function WriteDimensionArray(fd,dims)
-    // Copyright INRIA
-    // Write dimensions of an array
-    // VC
-
-    WriteSimpleElement(fd,dims,miINT32);
-endfunction
-
-function WriteArrayName(fd,ArrayName)
-    // Copyright INRIA
-    // Write name of an array
-    // VC
-
-    WriteSimpleElement(fd,ascii(ArrayName),miINT8);
-endfunction
-
-function WriteTag(fd,DataType,NumberOfBytes,Compressed)
-    // Copyright INRIA
-    // Write a tag
-    // VC
-
-    SavePos=mtell(fd);
-
-    if argn(2)==3 then
-        Compressed=%F;
-    end
-    Compressed=NumberOfBytes<=4;
-
-    if Compressed then
-        mseek(SavePos-NumberOfBytes-TagSize/2,fd);
-        mput(NumberOfBytes,md_s,fd);
-        mput(DataType,md_s,fd);
-    else
-        mseek(SavePos-NumberOfBytes-TagSize,fd);
-        mput(DataType,md_i,fd);
-        mput(NumberOfBytes,md_i,fd);
-    end
-
-    mseek(SavePos,fd);
-endfunction
-
-function WriteSimpleElement(fd,value,DataType)
-    // Copyright INRIA
-    // Write an element in file
-    // VC
-
-    // If data is of double type
-    // and made of integer values
-    // then it is writen in an INT* format to save space
-    if DataType==miDOUBLE & and(double(int(value))==value) then
-        if min(value)>=0 & max(value)<=255 then // min and max value for int8
-            DataType=miUINT8;
-        elseif min(value)>=-128 & max(value)<=127 then // min and max value for int8
-            DataType=miINT8;
-            //miINT8 replaced by miINT16 due to an error somewhere (matlab or
-            //scilab?) the generated file gives incorrect result in Matlab!
-            //example:
-            //  scilab var=-40;savematfile('foosci.mat','var','-mat','-v6');
-            //  matlab load foosci.mat;var
-            DataType=miINT16;
-
-        elseif min(value)>=0 & max(value)<=65535 then // min and max value for int16
-            DataType=miUINT16;
-        elseif min(value)>=-32768 & max(value)<=32767 then // min and max value for int16
-            DataType=miINT16;
-        elseif min(value)>=0 & max(value)<=4294967295 then // min and max value for int32
-            DataType=miINT32;
-        elseif min(value)>=-2147483648 & max(value)<=2147483647 then // min and max value for int32
-            DataType=miINT32;
-        end
-    end
-
-    NumberOfValues=length(value);
-
-    WriteEmptyTag(fd);
-
-    select DataType
-    case miDOUBLE
-        NumberOfBytes=NumberOfValues*8;
-        fmt=md_d;
-    case miINT8
-        NumberOfBytes=NumberOfValues;
-        fmt="c";
-    case miUINT8
-        NumberOfBytes=NumberOfValues;
-        fmt="uc";
-    case miINT16
-        NumberOfBytes=NumberOfValues*2;
-        fmt=md_s;
-    case miUINT16
-        NumberOfBytes=NumberOfValues*2;
-        fmt="u"+md_s;
-    case miINT32
-        NumberOfBytes=NumberOfValues*4;
-        fmt=md_i;
-    case miUINT32
-        NumberOfBytes=NumberOfValues*4;
-        fmt="u"+md_i;
-    else
-        error(msprintf(gettext("Error while writing MI."),string(DataType)));
-    end
-
-    Compressed=NumberOfBytes<=4;
-    if Compressed then
-        mseek(mtell(fd)-TagSize/2,fd);
-    end
-
-    mput(value,fmt,fd);
-
-    WriteTag(fd,DataType,NumberOfBytes);
-
-    WritePaddingBytes(fd);
-
-endfunction
-
-function WritePaddingBytes(fd)
-    // Copyright INRIA
-    // Write padding bytes to have a number of bytes multiple of 8
-    // VC
-
-    np=modulo(8-modulo(mtell(fd),8),8);
-    for k=1:np
-        mput(0,"uc",fd);
-    end
-endfunction
-
-function i=bits2byte(b)
-    // Copyright INRIA
-    // Converts 4-bits value to a byte value
-    // VC
-
-    i=b* 2^(0:3)';
-endfunction
index 36b1d4c..5be614f 100644 (file)
@@ -163,11 +163,11 @@ function [snd]=read_sndhdr(fid)
         error("Not a .au sound file.")
     end
 
-    snd("offset")=mget(1,"ulb",fid)
-    snd("databytes")=mget(1,"ulb",fid)
-    snd("format")=mget(1,"ulb",fid)
-    snd("rate")=mget(1,"ulb",fid)
-    snd("chans")=mget(1,"ulb",fid)
+    snd("offset")=mget(1,"uib",fid)
+    snd("databytes")=mget(1,"uib",fid)
+    snd("format")=mget(1,"uib",fid)
+    snd("rate")=mget(1,"uib",fid)
+    snd("chans")=mget(1,"uib",fid)
 
     // Directly determine how long info string is:
     info_len = snd("offset")-24;
index 7b620c8..50b3627 100644 (file)
@@ -158,11 +158,11 @@ function [snd]=write_sndhdr(fid,Fs,nbits,method,sz)
     snd("info")="SCI0";
 
     mput(ascii(".snd"),"c",fid); // magic number
-    mput(snd("offset"),"ulb",fid); // data location
-    mput(snd("databytes"),"ulb",fid); // size in bytes
-    mput(snd("format"),"ulb",fid); // data format
+    mput(snd("offset"),"uib",fid); // data location
+    mput(snd("databytes"),"uib",fid); // size in bytes
+    mput(snd("format"),"uib",fid); // data format
     //
-    mput(snd("rate")/snd("chans"),"ulb",fid); // sample rate
-    mput(snd("chans"),"ulb",fid); // channels
+    mput(snd("rate")/snd("chans"),"uib",fid); // sample rate
+    mput(snd("chans"),"uib",fid); // channels
     mput(ascii(snd("info")),"c",fid);  // info
 endfunction
index 6c8a098..355f322 100644 (file)
@@ -137,7 +137,7 @@ function savewave(filename,x,rate,nbits)
                 // Scale data according to bits/samples: [-1,+1] -> [-8 388 608,+8 388 607]
                 data = round((data+1)*(2^24-1)/2)-(2^23);
             case 4 then
-                dtype="l"
+                dtype="i"
                 // signed 32-bit
                 // Scale data according to bits/samples: [-1,+1] -> [-2 147 483 648,+2 147 483 647]
                 data = round((data+1)*(2^32-1)/2)-(2^31);
index 8a46786..f6ab9ca 100644 (file)
@@ -271,7 +271,7 @@ function Data = read_dat_pcm(fid,total_bytes , nChannels, nBitsPerSample, ext, w
         if wFormatTag == 3 then
             dtype = "f";
         else
-            dtype = "l";
+            dtype = "i";
         end
     else
         error(msprintf(gettext("%s: An error occurred: %s\n"), "read_dat_pcm", gettext("Cannot read .wav file  with more than 16 bits per sample.")));