New features commited

8 Messages Forum Options Options
Embed this topic
Permalink
Markus Meyer
New features commited
Reply Threaded MoreMore options
Print post
Permalink
Hi everyone,

I commited the following things:

1. Unicode: Audacity now compiles on GTK2 Unicode again. Note that there
may still be runtime problems with Unicode (e.g. with message boxes and
file names in the new clean speech code, GCC warnings give hints about that)

2. Some bugfixes to the cut lines feature (though unfortunately they're
still quite buggy)

3. When two clips are now put next to each other on the list, a thick
line appears. If you click on this line, the clips will be merged to
form one clip. The user interface is very much subject to discussion. I
for one would like to have some button right to the line that
automatically appears in this case (or something). Or at the very least
a tool tip.


Markus



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vaughan Johnson
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
I still have some questions about Unicode on the Windows build. I asked
some of this before, but maybe that email got lost, and I think some are
relevant to Linux.


1) string literals. Many places in the code, there are implicit
concatenations, where for readability, a string is split across multiple
lines, e.g.:

         wxMessageBox(_("CleanSpeech only allows recording mono track.\n"
                        "Recording not possible when more than one
window open."),
                        _("Recording not permitted"),
                        wxOK | wxICON_INFORMATION,
                        this);

This compiles fine in MSVC for Debug or Release build, but not Unicode:

    audacity\src\ControlToolBar.cpp(882) : error C2308: concatenating
mismatched wide strings

In some places the offending code can be replaced with wxT("xxx") +
wxT("yyy"), but in args to _(), I think it must all be one string:

         wxMessageBox(_("CleanSpeech only allows recording mono
track.\nRecording not possible when more than one window open."),
                        _("Recording not permitted"),
                        wxOK | wxICON_INFORMATION,
                        this);
 
Is there a better way to do it?



2) This, line 51 in PlatformCompatibility.cpp:

         HANDLE findHandle = FindFirstFile((const char*)pathToFind,
&findData);

    generates this error:

    audacity\src\PlatformCompatibility.cpp(51) :
        error C2440: 'type cast' : cannot convert from 'wxString' to
'const char *'

Should that be (const char*)(pathToFind.mb_str())?



3) Calls to one-byte fns, e.g.,

   wxFFile file(fopen(FILENAME(mFileName.GetFullPath()).fn_str(), "wb"));

generate

    audacity\src\blockfile\SimpleBlockFile.cpp(56) : error C2664: 'fopen' :
        cannot convert parameter 1 from 'const wxChar *' to 'const char *'

It seems to me GCC should have the same error. I think the right fix is:

   #ifdef _UNICODE
      wxFFile file(_wfopen(FILENAME(mFileName.GetFullPath()).fn_str(),
L"wb"));
   #else // ANSI
      wxFFile file(fopen(FILENAME(mFileName.GetFullPath()).fn_str(), "wb"));
   #endif // Unicode/ANSI

Right?



4) That being the case, what about calls to lib fns that don't have a
wide-char version, e.g.,

   SNDFILE *sf=sf_open(FILENAME(mFileName.GetFullPath()).fn_str(),
SFM_READ, &info);

which generates

    audacity\src\blockfile\SimpleBlockFile.cpp(196) :
        error C2664: 'sf_open' : cannot convert parameter 1 from 'const
wxChar *' to 'const char *'


Do we need to write wide versions and call them based on #ifdef
_UNICODE, or will this work?

   wxString filenameStr = FILENAME(mFileName.GetFullPath()).fn_str();
   SNDFILE *sf=sf_open(filenameStr.mb_str(), SFM_READ, &info);



I think these file-handling things must be fixed for it to actually work
with Unicode on Linux, right?

And I understand that Unicode is not essential for Windows, but I did
read that modern versions of Windows are based on Unicode, and that the
code should run faster in Unicode, because the OS won't have to keep
translating between Unicode and ANSI. Of course, we don't do that much
string-handling...

-Vaughan



Markus Meyer wrote:

> ...Unicode: Audacity now compiles on GTK2 Unicode again. Note that
> there may still be runtime problems with Unicode (e.g. with message
> boxes and file names in the new clean speech code, GCC warnings give
> hints about that)
>
>


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vaughan Johnson
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink


Vaughan Johnson wrote:

> ...
>
> 2) This, line 51 in PlatformCompatibility.cpp:
>
>         HANDLE findHandle = FindFirstFile((const char*)pathToFind,
> &findData);
>
>    generates this error:
>
>    audacity\src\PlatformCompatibility.cpp(51) :
>        error C2440: 'type cast' : cannot convert from 'wxString' to
> 'const char *'
>
> Should that be (const char*)(pathToFind.mb_str())?
>


Actually, that doesn't compile. What compiles in Debug, Release, &
Unicode_Debug is:

         HANDLE findHandle = FindFirstFile(pathToFind.c_str(), &findData);

-V


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Tuomas Suutari
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
On Wednesday 22 June 2005 02:19, Vaughan Johnson wrote:
> Actually, that doesn't compile. What compiles in Debug, Release, &
> Unicode_Debug is:
>
>          HANDLE findHandle = FindFirstFile(pathToFind.c_str(),
> &findData);

That compiles, but for filenames it would be more correct to use:

HANDLE findHandle = FindFirstFile(pathToFind.fn_str(), &findData);

(fn stands for filename)

I'm not really sure why there are both c_str() and fn_str(). Maybe in
some configurations they use different encoding.

--
Tuomas Suutari | +358 50 3806983 | thsuut@...


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vaughan Johnson
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
Tuomas Suutari wrote:

>On Wednesday 22 June 2005 02:19, Vaughan Johnson wrote:
>  
>
>>Actually, that doesn't compile. What compiles in Debug, Release, &
>>Unicode_Debug is:
>>
>>         HANDLE findHandle = FindFirstFile(pathToFind.c_str(),
>>&findData);
>>    
>>
>
>That compiles, but for filenames it would be more correct to use:
>
>HANDLE findHandle = FindFirstFile(pathToFind.fn_str(), &findData);
>
>(fn stands for filename)
>
>I'm not really sure why there are both c_str() and fn_str(). Maybe in
>some configurations they use different encoding.
>
>  
>

You're right. Thanks!

-Vaughan


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Markus Meyer
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
In reply to this post by Vaughan Johnson
Vaughan Johnson schrieb:

> 1) string literals. Many places in the code, there are implicit
> concatenations, where for readability, a string is split across
> multiple lines, e.g.:
>
>         wxMessageBox(_("CleanSpeech only allows recording mono track.\n"
>                        "Recording not possible when more than one
> window open."),
>                        _("Recording not permitted"),
>                        wxOK | wxICON_INFORMATION,
>                        this);
>
> This compiles fine in MSVC for Debug or Release build, but not Unicode:

No idea about this. Works fine on GCC for me.


> 2) This, line 51 in PlatformCompatibility.cpp:
>
>         HANDLE findHandle = FindFirstFile((const char*)pathToFind,
> &findData);
>
>    generates this error:
>
>    audacity\src\PlatformCompatibility.cpp(51) :
>        error C2440: 'type cast' : cannot convert from 'wxString' to
> 'const char *'
>
> Should that be (const char*)(pathToFind.mb_str())?

That should be pathToFind.c_str(), because FindFirstFile automatically
is 16-bit or 8-bit depending on the build.

>
> 3) Calls to one-byte fns, e.g.,
>
>   wxFFile file(fopen(FILENAME(mFileName.GetFullPath()).fn_str(), "wb"));

It should be wxFFile file(FILENAME(mFileName.GetFullPath()).c_str(),
"wb") because wxFFile (and also wxFile) already have a wxChar
constructor. IIRC this is wrong in the wx documentation (it still
contains the wxFFile::wxFFile(const char*, const char*) constructor).

> 4) That being the case, what about calls to lib fns that don't have a
> wide-char version, e.g.,
>
>   SNDFILE *sf=sf_open(FILENAME(mFileName.GetFullPath()).fn_str(),
> SFM_READ, &info);
>
> which generates
>
>    audacity\src\blockfile\SimpleBlockFile.cpp(196) :
>        error C2664: 'sf_open' : cannot convert parameter 1 from 'const
> wxChar *' to 'const char *'

Just use mb_str() which always returns 8-bit. The only drawback will be
that it may not be possible to open the file when the conversion to
8-bit fails (but this is a problem of libsndfile, which does not support
unicode strings). I think it is a platform-defined behaviour which
encoding is used and expected within these calls.

> I think these file-handling things must be fixed for it to actually
> work with Unicode on Linux, right?
>
> And I understand that Unicode is not essential for Windows, but I did
> read that modern versions of Windows are based on Unicode, and that
> the code should run faster in Unicode, because the OS won't have to
> keep translating between Unicode and ANSI. Of course, we don't do that
> much string-handling...

The problem with Unicode is that many Linux distributions come with
Unicode-enabled libs by default so it is important to support Unicode or
the user will have to re-install wx libraries, and sometimes GTK. Of
course, Unicode is also a good thing to support per se. The main problem
I see is that the whole Unicode thing cannot really be tested in western
countries (even in Germany we don't really need Unicode for our umlauts
and stuff, and with a system-wide codepage of ISO-8859-1 or so things
"just work" most of the time). So the best thing would be to have a
contributor / developer from a country like China or so. Otherwise I
think it is rather difficult to find and fix bugs.

For the Windows developers, maybe it would be good practice to create
the Unicode build next time you update your wxWidgets installation (if
you happen to have Windows 2000 or Windows XP, that is). This would help
development on Linux. The release builds should still be created with
8-bit support on Windows (because otherwise they won't work on Win98, e.g.).


Markus



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vaughan Johnson
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
Markus Meyer wrote:

> Vaughan Johnson schrieb:
>
>> 1) string literals. Many places in the code, there are implicit
>> concatenations, where for readability, a string is split across
>> multiple lines, e.g.:
>>
>>         wxMessageBox(_("CleanSpeech only allows recording mono track.\n"
>>                        "Recording not possible when more than one
>> window open."),
>>                        _("Recording not permitted"),
>>                        wxOK | wxICON_INFORMATION,
>>                        this);
>>
>> This compiles fine in MSVC for Debug or Release build, but not Unicode:
>
>
> No idea about this. Works fine on GCC for me.


There's another way, I didn't know about, just using backslash. From
MSVC "C Language Reference":

        "Long strings can be bro\
        ken into two or more pieces."

    is identical to the string

        "Long strings can be broken into two or more pieces."

It compiles in MSVC Unicode, but is that a Visual C extension only? Will
you please try it on GCC & let me know? There are lots of occurrences,
and I've already made most of them non-contenated strings, but putting
them on multiple lines is a lot easier to read & edit.


>
>
>> 2) This, line 51 in PlatformCompatibility.cpp:
>>
>>         HANDLE findHandle = FindFirstFile((const char*)pathToFind,
>> &findData);
>>
>>    generates this error:
>>
>>    audacity\src\PlatformCompatibility.cpp(51) :
>>        error C2440: 'type cast' : cannot convert from 'wxString' to
>> 'const char *'
>>
>> Should that be (const char*)(pathToFind.mb_str())?
>
>
> That should be pathToFind.c_str(), because FindFirstFile automatically
> is 16-bit or 8-bit depending on the build.


Right, thanks, but fn_str(), as Tuomas Suutari pointed out.



>
>>
>> 3) Calls to one-byte fns, e.g.,
>>
>>   wxFFile file(fopen(FILENAME(mFileName.GetFullPath()).fn_str(), "wb"));
>
>
> It should be wxFFile file(FILENAME(mFileName.GetFullPath()).c_str(),
> "wb") because wxFFile (and also wxFile) already have a wxChar
> constructor. IIRC this is wrong in the wx documentation (it still
> contains the wxFFile::wxFFile(const char*, const char*) constructor).


Excellent. I was sticking the with wxFFile(FILE* fp) constructor because
the documentation says char*, even though it's actually wxChar*. Serves
me right for believing the documentation!

To be picky, the 2nd arg needs wxT(), so it should be:
    wxFFile summaryFile(FILENAME(mFileName.GetFullPath()).fn_str(),
wxT("wb")));



>
>> 4) That being the case, what about calls to lib fns that don't have a
>> wide-char version, e.g.,
>>
>>   SNDFILE *sf=sf_open(FILENAME(mFileName.GetFullPath()).fn_str(),
>> SFM_READ, &info);
>>
>> which generates
>>
>>    audacity\src\blockfile\SimpleBlockFile.cpp(196) :
>>        error C2664: 'sf_open' : cannot convert parameter 1 from
>> 'const wxChar *' to 'const char *'
>
>
> Just use mb_str() which always returns 8-bit. The only drawback will
> be that it may not be possible to open the file when the conversion to
> 8-bit fails (but this is a problem of libsndfile, which does not
> support unicode strings). I think it is a platform-defined behaviour
> which encoding is used and expected within these calls.


Okay, I'll do it that way for now and put a note that it may break.


>
>> I think these file-handling things must be fixed for it to actually
>> work with Unicode on Linux, right?
>>
>> And I understand that Unicode is not essential for Windows, but I did
>> read that modern versions of Windows are based on Unicode, and that
>> the code should run faster in Unicode, because the OS won't have to
>> keep translating between Unicode and ANSI. Of course, we don't do
>> that much string-handling...
>
>
> The problem with Unicode is that many Linux distributions come with
> Unicode-enabled libs by default so it is important to support Unicode
> or the user will have to re-install wx libraries, and sometimes GTK.
> Of course, Unicode is also a good thing to support per se. The main
> problem I see is that the whole Unicode thing cannot really be tested
> in western countries (even in Germany we don't really need Unicode for
> our umlauts and stuff, and with a system-wide codepage of ISO-8859-1
> or so things "just work" most of the time). So the best thing would be
> to have a contributor / developer from a country like China or so.
> Otherwise I think it is rather difficult to find and fix bugs.
>
> For the Windows developers, maybe it would be good practice to create
> the Unicode build next time you update your wxWidgets installation (if
> you happen to have Windows 2000 or Windows XP, that is). This would
> help development on Linux. The release builds should still be created
> with 8-bit support on Windows (because otherwise they won't work on
> Win98, e.g.).
>
>
> Markus
>

Thanks for all that info, Markus. I've got a Unicode Debug version
building on Windows, & it records, but all the effects zero out the
waveform -- maybe a filenaming thing. If you or some other developers
will let me know about that string concatenation thing, I'll check it
in. The 8-bit builds are still working.

Thanks,
Vaughan


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vaughan Johnson
Re: New features commited (Unicode)
Reply Threaded MoreMore options
Print post
Permalink
I just committed all the Unicode -> MSVC stuff I've been working on.

Vaughan Johnson wrote:

> Markus Meyer wrote:
>
>> Vaughan Johnson schrieb:
>>
>>> 1) string literals. Many places in the code, there are implicit
>>> concatenations, where for readability, a string is split across
>>> multiple lines, e.g.:
>>>
>>>         wxMessageBox(_("CleanSpeech only allows recording mono
>>> track.\n"
>>>                        "Recording not possible when more than one
>>> window open."),
>>>                        _("Recording not permitted"),
>>>                        wxOK | wxICON_INFORMATION,
>>>                        this);
>>>
>>> This compiles fine in MSVC for Debug or Release build, but not Unicode:
>>
>>
>>
>> No idea about this. Works fine on GCC for me.
>
>
>
> There's another way, I didn't know about, just using backslash. From
> MSVC "C Language Reference":
>
>        "Long strings can be bro\
>        ken into two or more pieces."
>
>    is identical to the string
>
>        "Long strings can be broken into two or more pieces."
>
> It compiles in MSVC Unicode, but is that a Visual C extension only?
> Will you please try it on GCC & let me know? There are lots of
> occurrences, and I've already made most of them non-contenated
> strings, but putting them on multiple lines is a lot easier to read &
> edit.


Most of the long strings I committed are just single lines now, with a
few using the \ concatenation. Let me know if they don't compile elsewhere.


>
> ...
>
>>
>>
>> For the Windows developers, maybe it would be good practice to create
>> the Unicode build next time you update your wxWidgets installation
>> (if you happen to have Windows 2000 or Windows XP, that is). This
>> would help development on Linux. The release builds should still be
>> created with 8-bit support on Windows (because otherwise they won't
>> work on Win98, e.g.).
>>
>>
>>
>
> Thanks for all that info, Markus. I've got a Unicode Debug version
> building on Windows, & it records, but all the effects zero out the
> waveform -- maybe a filenaming thing. If you or some other developers
> will let me know about that string concatenation thing, I'll check it
> in. The 8-bit builds are still working.
>
>

The stuff I just committed still has bugs in the effects, and is Unicode
Debug but not Unicode Release yet, but I thought it's time to check it
in & let others see it.

I did build wxWidgets 2.6.0 in all 4 configs (Debug, Release, Unicode
Debug, & Unicode Release). I've added those wxWidgets MSVC7 project
files to HEAD, in "audacity\win\wxWidgets_additions", and updated
"compile.txt" for all this (and some MSVC7 stuff that wasn't in there
yet). The section on building wxWidgets got simpler because you no
longer need to edit the wxWidgets projects to build statically linked
libs instead of DLLs, just copy the Audacity MSVC7 solution and projects
and use them instead of the wxWidgets MSVC6 workspace & projects.

-Vaughan


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Audacity-devel mailing list
Audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel