Home   Archive   Permalink



Save WAV

>> read %/c/windows/media/tada.wav
== {RIFF$Z^D^@WAVEfmt ^P^@^@^@^A^@^B^@D¬^@^@^P±^B^@^D^@^P^@data^@Z^D^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
@^@^@^@^@^@^@^@^@^@^@^@^@^...
>> wav1: load %/c/windows/media/tada.wav
>> ? wav1
WAV1 is an object of value:
     type            word!     sound
     rate            integer! 44100
     channels        integer! 2
     bits            integer! 16
     volume         decimal! 0.5
     data            binary! #{ 80008000800080008000800080008000800080008000800...
    
>> save %a.wav wav1
>> wav2: load %a.wav
== [make object! [
         type: 'sound
         rate: 44100
         channels: 2
         bits: 16
         volume: 0.5
         d...
>> read %a.wav
== {make object! [
     type: 'sound
     rate: 44100
     channels: 2
     bits: 16
     volume: 0.5
     data: #{
800080008000800080008...
    
how to save file in correct wav format? To make tada.wav and a.wav the same...

posted by:   Sergey_Vl     11-Jul-2022/7:43:06-7:00



Probably
write/binary %a.wav wav1/data
or perhaps
save/as %a.wav wav1 'wav
in Red.

posted by:   Kaj     13-Jul-2022/8:53:13-7:00



A WAV file must have a header, and wav1/data is data without a header.
Now I take the header from another file:
    
header: read/binary/part %/c/windows/media/tada.wav 43
write/binary file header
write/append/binary file to-binary wav/data
    
but this is probably wrong.
    
Red doesn't seem to know how to work with sound files at all:
    
>> wav: load %/c/windows/media/tada.wav
*** Access Error: invalid UTF-8 encoding: #{AC000010}
*** Where: transcode
*** Near : %/c/windows/media/tada.wav
*** Stack: load    
    
>> wav: read %/c/windows/media/tada.wav
*** Access Error: invalid UTF-8 encoding: #{AC000010}
*** Where: read
*** Near : %/c/windows/media/tada.wav
*** Stack:    
    
>> wav: load/as %/c/windows/media/tada.wav `wav
*** Script Error: `wav has no value
*** Where: load
*** Near : `wav
*** Stack: load    


posted by:   Sergey_Vl     14-Jul-2022/1:29:15-7:00



Did you use the right single quote on 'wav?

posted by:   Kaj     14-Jul-2022/3:25:52-7:00



Incorrect quote, but even changing it did not help
    
>> wav: load/as %tada.wav `wav
*** Script Error: `wav has no value
*** Where: load
*** Near : `wav
*** Stack: load    
    
>> wav: load/as %tada.wav 'wav
*** Script Error: invalid /as argument: wav
*** Where: do
*** Near : args
*** Stack: load cause-error    
    
>> about
Red 0.6.4 for Windows built 4-Jul-2022/18:48:56+10:00 commit #ccc7e08

posted by:   Sergey_Vl     14-Jul-2022/18:57:04-7:00



Pardon the pun, but it sounds like REBOL and Red don't support much sound.

posted by:   Kaj     15-Jul-2022/5:33:21-7:00



Rebol2 is the most complete in terms of functionality, and neither R3 nor Red have been able to compare with it so far.

posted by:   Sergey_Vl     15-Jul-2022/7:49:42-7:00



Oldes' R3 has more LOAD codecs, but it doesn't seem to support SAVE types.

posted by:   Kaj     15-Jul-2022/8:11:25-7:00



We're in the same situation as Linux distros: Linux can do everything you want, but there is never one Linux distro that does everything you need.

posted by:   Kaj     15-Jul-2022/8:14:53-7:00



My R3 supports WAV saving.. check https://github.com/Oldes/Rebol3/blob/90b97564c64d60bd8391f3d69754e184517ebf33/src/tests/units/codecs-test.r3#L160


posted by:   Oldes     19-Jul-2022/4:06:38-7:00



Something wrong...
    
in Rebol2
>>a: %adat.wav write/binary %tada.wav append read/part a 43 reverse skip read/binary a 43
saves a correct/playable wav file with "inverted" sound.
    
in Rebol3
>> a: load/as %tada.wav 'wav
>> a/data: reverse to-binary a/data
>> save %adat.wav a
>> a/data: reverse to-binary a/data
>> save %tada_2.wav a
    
the %adat.wav file has data shifted one byte to the right, and is played with distortion
file %tada_2.wav is completely identical to %tada.wav
    
perhaps "to-binary" does not correctly handle two-byte values with zeros on the edges?

posted by:   Sergey_Vl     19-Jul-2022/8:18:48-7:00



BINARY! is a generic series of bytes. If you have multi-byte values, you need to do the rest of decoding and encoding yourself.
    
Also, wav/data is already BINARY!, so you shoudln't need to-binary. And REVERSE works in-place, so you don't need to reassign wav/data.
    
Note that Meta will have arrays of other types than bytes, for example NATURAL16!, so you will be able to access data such as wavs more naturally and more efficiently.

posted by:   Kaj     19-Jul-2022/13:22:20-7:00



wav/data is VECTOR!
    
>> a: load/as %tada.wav 'wav
Decode WAV data ( 285228 bytes )
CHUNK: at: 21     bytes: 16
CHUNK: at: 45     bytes: 285184
== make object! [
     type: 'wave
     rate: 44100
     channels: 2
     bits: 16
     chunks: [
         [1 2 44100 176400 4 16]
         285184
     ]
     data: make vector! [integer! 16 142592 [
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0 0 0 0 0 0
         0 0 0 0 0
    
>> type? a/data
== vector!
    
>> reverse a/data
** Script error: cannot use reverse on vector! value
** Where: reverse
** Near: reverse a/data
    
In Rebol2, the sound turns over to the ear normally. If you do not add /binary, then the return of the 0Ah correction is added to the line feed byte 0Dh and the sound deteriorates.
    
About Meta - I'm waiting for its development and I hope that it will be possible to use it locally, without being tied to a third-party service/Internet.

posted by:   Sergey_Vl     19-Jul-2022/18:25:47-7:00



Is that R3? In your R2 example it was BINARY!.
    
A 16-bit VECTOR! should process naturally.
    
Local Meta will happen eventually, but it is years away. It will probably be a slower interpreter.

posted by:   Kaj     20-Jul-2022/4:55:10-7:00



In R3, you're converting the vector to binary and then you're reversing it, so all the 16-bit samples have their bytes swapped.

posted by:   Kaj     20-Jul-2022/4:59:38-7:00



VECTOR! is not BINARY! ? Where can I learn more about this type? There is not much information in the official documentation (http://www.rebol.com/r3/docs/datatypes/vector.html).
    
if move data from reverse file (1 byte in tada.wav or 83 byte in Ring03.waw (c:/windows/media)) then the data in the files created in R2 and R3 become identical and correct when played back.

posted by:   Sergey_Vl     20-Jul-2022/8:55:20-7:00



find in Red (https://github.com/red/docs/blob/master/en/datatypes/vector.adoc) is it correect to R3?
but Red can reverse vector:
>> a: make vector! [1 2 3 4 5 3]
== make vector! [1 2 3 4 5 3]
>> ? a
A is a vector! value. length: 6 make vector! [1 2 3 4 5 3]
>> reverse a
== make vector! [3 5 4 3 2 1]

posted by:   Sergey_Vl     20-Jul-2022/9:01:33-7:00



BINARY! and VECTOR! are different types. BINARY! is like a byte VECTOR!, but it existed much earlier, so the type system is not completely consistent anymore.
    
I don't know of any other VECTOR! documentation than the official ones, and I don't know if the Red implementation is completely compatible with R3.

posted by:   Kaj     20-Jul-2022/11:02:33-7:00



Uhmm Meta...no other programming language forces you to depend on a server to compile a program.
    
I guess being dependent on someone and lack of privacy will two strength of Meta.

posted by:   Steven_o     21-Jul-2022/1:54:09-7:00



Steven_o, you forgot about Anvil :)
But seriously, I think the current implementation and the closeness of the Mata code are connected only with the desire of Kaj to finish it to the first version and only then open / publish the server part. So that there is no branching of a language that has not been fully thought out and completed.

posted by:   Sergey_Vl     21-Jul-2022/9:09:28-7:00



Sergey, yes, that's one of the reasons. The code is currently fairly experimental and not fit for release.
    
Steven, as I said above, local Meta will happen. But it's a lot more work, and I don't have a magic hat to pull it from.
    
There are plenty of service- or even web-based development platforms, indeed including Anvil. They are very popular. Also, many people and organisations just host their source code with external providers.
    
I agree that independence and resilience are important. But it's hard to imagine being more dependent than on the creator of your daily programming language, whichever way you turn it. If you don't trust him, you definitely shouldn't use it. On the other hand, if you want to make local Meta the top priority, you can contact me privately to fund it:
language.metaproject.frl#when

posted by:   Kaj     21-Jul-2022/13:09:35-7:00



Anvil is a Saas. Personally I wouldn't want to hand my entire business to a company like Anvil which can and will shut you down or change policies at any time and for any reason.
    
Python, C, Php, Go, Rust, Rebol, Red and the rest of programming languages I use regularly are Programming Laguages not compilers the cloud.
    
I don't depend on Van Rossum, Ritchie, Lerdorf or any of them.
    
If the creator of Rebol stops developing it, as it has happened I am still able to write Rebol programs, compile them and run them and even fork it like Oldes and others have done.
    
I don't have many resources. How much money are you looking for and what would be your timeline ? Is your end goal a programming language as a subscription ?

posted by:   Steven_o     21-Jul-2022/14:16:35-7:00



Creators of REBOL - and other - projects stopping is historically a serious problem. Usually, noone is willing or able to continue them. I tried to go along for a quarter century, but it ruined me, so now it's the reason for creating Meta.
    
The goals are here:
language.metaproject.frl#goals
    
There will be a mix of products, including subscription services, but as you can see, that's not the only goal or the end goal. We'll see what works. Funding of open-source projects is a well-known problem, so I have to be creative.
    
As I mentioned, in the current timeline, local Meta is years away, because it depends on a lot of other work. So currently, it would require substantial funding and changes to the development plan to do it earlier. It would still take considerable time, because a lot of dependent work would also need to be accelerated.
    
On the other hand, if you have patience, the dependent work will be done first, hopefully with some funding, and there will come a point where local Meta will be the next logical step.

posted by:   Kaj     21-Jul-2022/15:09:20-7:00



To be clear, there is an open source version of Anvil server. I run an automated backup routine of all my apps and data, so that I can pop everything up to a self-hosted server if Anvil's hosted product ever get hit by an asteroid. And to be doubly clear, I do the same thing with any Rebol web app hosted on a third party server. Running web apps in *any* environment typically relies on third party servers. I wouldn't use Anvil if there wasn't a drop-in open source replacement.

posted by:   Nick     22-Jul-2022/13:07:58-7:00



I'm amazed that people make such broad and critical comments as:
    
'Anvil is a Saas. Personally I wouldn't want to hand my entire business to a company like Anvil which can and will shut you down or change policies at any time and for any reason.'
    
without doing any research.
    
'Anvil offers an SAAS solution for convenience, but you're not required to use it.'
    
is instead correct.

posted by:   Nick     22-Jul-2022/13:49:57-7:00



Please post any responses to this topic in the 'What I'm using now instead of Rebol' thread.

posted by:   Nick     22-Jul-2022/13:51:30-7:00



@Sergey_Vl if you have any issue or a wish (like to reverse a vector) with Rebol3 (especially with my version), than you should use https://github.com/Oldes/Rebol-issues/issues or https://gitter.im/rebol3/community

posted by:   oldes     8-Aug-2022/17:29:52-7:00



It is now possible to reverse a vector with this change: https://github.com/Oldes/Rebol3/commit/24faca96ffe7882a0c6ab82354035f646e4aaa4e

posted by:   oldes     9-Aug-2022/17:48:45-7:00



Also.. instead of
```
a: load/as %tada.wav 'wav
```
one can write just:
```
a: load %tada.wav
```

posted by:   oldes     9-Aug-2022/17:50:15-7:00



Oldes, thank you very much.

posted by:   Sergey_Vl     10-Aug-2022/8:02:09-7:00



Name:


Message:


Type the reverse of this captcha text: "h c a e - e v o m e r"



Home