Fun with code (since 2006)

Writing a new book : What can you do with bytes ?


04.26.09 Posted in Actionscript 3, Books & Articles, ByteArray by

What can you do with bytes ?Writing the previous book was a very interesting experience. A few days ago, I decided to start the writing of a new book called "What can you do with bytes in ActionScript 3 ?"

The idea is to cover different topics (through 7 chapters) related to binary and discover some cool things you can do with it in ActionScript 3.

This book will be free and available as a downloadable PDF like the first version of "Pratique d'ActionScript 3". I will write it in English so that everybody can read it (this time!) :)

English reviewers will be very welcome to improve my English through the chapters ! :)

Download :

Chapter 1 - The first bits
Chapter 2 - Everyday bytes
Chapter 3 - Encoders
Chapter 4 - Parsers
Chapter 5 - Low-level networking
Chapter 6 - External devices
Chapter 7 - Emulators



145 Responses to “Writing a new book : What can you do with bytes ?”

  1. [...] hard to find time for writing lately, but this week end I found the time to finish the chapter 2 of What can you do with bytes ? I know I am late, but I hope you guys will like this second chapter. At the Flash Gaming Summit I [...]

     
  2. [...] http://www.bytearray.org/?p=711 This entry was posted on Monday, March 14th, 2011 at 5:25 pmand is filed under AS3. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. [...]

     
  3. Alexander Schimek says:

    thank you very much for this update!!!

  4. [...] hard to find time for writing lately, but this week end I found the time to finish the chapter 2 of What can you do with bytes ? I know I am late, but I hope you guys will like this second chapter. At the Flash Gaming Summit I [...]

     
  5. tiTano says:

    Hi Thib,
    I started reading the first chapter this morning. Found it very very intersting!

    But there is something strange:

    At page 16 you tested performance for bitwise operator:
    “In terms of performance, it may be advantageous to use this technique to divide or multiply a
    value. In the following code we use the traditional division operator…”

    I tested on Incubator an current 10.2 debug player and surprisingly it results the traditional way is slightly faster than using bitwise shift…

  6. [...] Представляю вашему вниманию перевод главы «Chapter 2 – Everyday bytes» (PDF) из книги «What can you do with bytes ?» [...]

     
  7. Ezell says:

    This is awesome, I want to learn the nuts and bolts of these things looking for references can get very difficult at times.
    Thanks

  8. mihnea says:

    Hey Thibault,

    You could make a kindle version. I’ll be willing to pay for it and I don’t think I’m the only one :)

  9. Stephen says:

    On page 2 of Chapter 2, you set parameter.nom to “Stevie” – not parameters.name.

  10. Thibault Imbert says:

    Hi Stephen,

    Thanks! Updated.

    Thibault

  11. tom says:

    this is really cool book

  12. John says:

    Very well written, and so good of you to make it free.

    If it helps, I like to think of bits and bytes this way:

    Place 8 ‘bits’ of wire next to each other on a printed circuit board and use them to transfer data between memory and cpu. That’s a computer with an 8 bit ‘bus’. Like bus transfer! A byte is a collection of 8. Now we have 64 bit PCs that can bus 8 bytes at a time.

    John

  13. [...] here the fact that Thibault Imbert has written the 2nd chapter of his new book titled ‘ What can you do with bytes ? ‘ concerning the possibilities that the ByteArray class offers. In the first chapter Thibault [...]

     
  14. northWolf says:

    Hi,Mr Imbert,I’m very glad to see your blog at the moment,I’m a Chinese and I fall in love with AS3 at 2009, when I hope it isn’t too late.

  15. Thanks for taking the time for you to talk about this, I really feel strongly about it and adore learning much more on this subject. If feasible, as you acquire experience, would you thoughts updating your weblog with a lot more data? It’s extremely useful for me.

  16. zes says:

    Hi, Thibault.

    Tout d’abord merci pour tout ton travail et le partage de celui-ci ! Tes anciens livres m’ont permis de rentrer facilement dans le monde de AS3.

    Une chance que ce bouquin là soit un jour en français ???

  17. Thibault Imbert says:

    Salut Zes,

    Merci! Malheureusement ce livre n’a pas de version Francaise prevue.

    Thibault

  18. [...] was kind enough to let us download the first chapter called “The first bits. The complete book will be available on his website. And by the way, don’t hesitate to check [...]

     
  19. Parag Shah says:

    Bingo!!! I m sure it would be a worth wait and would be as super as Chapter 1…

  20. Ezell Burke says:

    Thank you man,
    You are my Hero. I am trying to understand How low level api’s are written like amf and socket api’s. This is wonderful help on my quest of understanding.

  21. Henke37 says:

    You should have used the extended wave format that allows you to save floating point values instead of integers. In theory you should get less conversion artifacts and such. But the input signal isn’t exactly clear enough for it to matter here.

  22. [...] was kind enough to let us download the first chapter called “The first bits. The complete book will be available on his website. And by the way, don’t hesitate to check [...]

     
  23. Will Streeter says:

    This is rather long… but the short of it is that I am trying to change the position at which a byteArray begins to play back its contents. Specifically contents that has been loaded through a mic recording in an AIR app

    I am developing an AIR application that enables a user to recording audio through a microphone, and then edit their recording. Simply recording the audio data into a byteArray and playing it back to the user unedited is not a problem. A very strange problem begin, however, once I change the start position of the byteArray. I must implement a scrubber that will enable the user to stop the sound in mid play back and start again from a different point. Thus, I have a byteArray containing some 4 million bytes (4000000) , I begin the play back of the byteArray at 0 position and when I play it back from a starting position of 0 it plays back each time perfectly. However, when I change the starting position to start at 2 million (2000000) for instance, the play back of the byteArray from the position of 2 million to the end, works the first time. When I close the application and recompile and try it again, and create another audio recording, the playback starting from the 0 position of the byteArray works perfectly, but the moment I change the starting position again to say 2 million out of million, all I get is hissing static when I play it back. Recompiling and repeating the process a third time, the play back from the 0 position is perfect, however, once again when I change the starting position of the byteArray, I get no sound at all.

    I started by just modifying the various examples that were used for showing how to playback recorded data from a byteArray that was demonstrated in the following project.

    http://download.macromedia.com/pub/developer/air/sample_apps/microphone.zip

    currentBufferingData.readBytes(recordedData, 0, currentBufferingData.length);

    changing the offset to a dynamic variable (currentVocalPosition) and subtracting the
    the currentVocalPosition from the total length of the byteArray for the length or amount of data to read.

    currentBufferingData.readBytes(recordedData, currentVocalPosition, (currentBufferingData.length-currentVocalPosition))

    as this did not work I tried using writeBytes and leaving of the length;

    recordedData.writeBytes(currentBufferingData,currentVocalPosition)

    All these different attempts yielded the same result:
    1st recompile: works
    2n recompile: static
    3rd reompile : silence nothing.

    Thinking that the byteArray was getting corrupted so how, I decided to create a clone of the byteArray each time I play it back. Thus, I create an array and assign the first index of the array with an empty byteArray to store an edited version of the original cloned copy of the original byteArray recording,
    this._dynamicArray[0] = new ByteArray();

    I then create a second cloned copy of the original byteArray recording and assign it to the second index of the dynamic array.

    this._dynamicArray[1] = this.micAssetMngr.getMicDataClone();

    I used this copy of the original byteArray to copy the parts of the byteArray that I want to playback. Thus, when a user has changed the current position of the byteArray, I take from this position to end of the byteArray as the portion of the sound I want to playback..

    Of course the results of this do not yield any better results. The same thing happens, it works the first time, and then after I recompile and try again all I get is hissing static when I change the starting position, and then of course on the third recompile and playback of new starting position I get nothing but silence.

    private function playRecordedData():void{
    this.playingVocalStarted = false;
    if(this.beat && this.hasEventListener(CuePointEvent.CUE_POINT)){
    this.beat.removeEventListener(CuePointEvent.CUE_POINT, onCuePoint);
    }

    if(this._dynamicArray.length>0){
    this._dynamicArray[0].position = 0;
    this._dynamicArray[0].clear();
    delete this._dynamicArray[0];
    this._dynamicArray.pop();
    System.gc();
    }

    this._dynamicArray[0] = new ByteArray();
    this._dynamicArray[1] = this.micAssetMngr.getMicDataClone();
    this._dynamicArray[0].clear();
    this._dynamicArray[0].length = 0;
    this._dynamicArray[0].writeBytes(this._dynamicArray[1], this.currentVocalPosition);
    this._dynamicArray[0].position = 0;

    this._dynamicArray[1].position = 0;
    this._dynamicArray[1].clear();
    delete this._dynamicArray[1];
    this._dynamicArray.pop();
    System.gc();

    /*2nd try
    this._dynamicArray[0] = new ByteArray();
    this._dynamicArray[1] = this.micAssetMngr.getMicDataClone();
    this._dynamicArray[0].clear();
    this._dynamicArray[0].length = 0;
    this._dynamicArray[0].writeBytes(this._dynamicArray[1]);
    this._dynamicArray[0].position = this.currentVocalPosition;

    this._dynamicArray[1].position = 0;
    this._dynamicArray[1].clear();
    delete this._dynamicArray[1];
    this._dynamicArray.pop();
    System.gc();
    */

    /*3rd try
    this._dynamicArray[0] = new ByteArray();
    this._dynamicArray[1] = this.micAssetMngr.getMicDataClone();
    var length:uint = this._dynamicArray[1].length – this.currentVocalPosition;
    this._dynamicArray[1].position = this.currentVocalPosition;
    this._dynamicArray[0].clear();
    this._dynamicArray[1].readBytes(this._dynamicArray[0], 0, length);
    this._dynamicArray[0].position = 0;

    if(this._dynamicArray.length>0){
    this._dynamicArray[1].position = 0;
    this._dynamicArray[1].clear();
    delete this._dynamicArray[1];
    this._dynamicArray.pop();
    System.gc();
    }
    */

    /*4th try
    var temp:ByteArray = this.micAssetMngr.getMicDataClone();

    while (temp.bytesAvailable > this.currentVocalPosition){
    this._dynamicArray[0].writeFloat(temp.readFloat());
    }
    */
    this.effectDriver.effectInit();
    if(this.vocal && this.vocal.hasEventListener(Event.SOUND_COMPLETE)){
    this.vocal.removeEventListener(Event.SOUND_COMPLETE, onVocalPlaybackComplete);
    }
    if(this.vocal && this.vocal.hasEventListener(SampleDataEvent.SAMPLE_DATA)){
    this.vocal.removeEventListener(SampleDataEvent.SAMPLE_DATA, playSoundHandler);
    }

    this.vocal = new SoundAssetManager();
    this.vocal.addEventListener(SampleDataEvent.SAMPLE_DATA, playSoundHandler);
    this.vocal.recordedPlayBack();
    this.vocal.name = SoundAssetManager.PLAYING_VOCAL;
    this.vocal.play(0);
    this.vocal.addEventListener(Event.SOUND_COMPLETE, onVocalPlaybackComplete);
    }

  24. Anonymous says:

    [...] [...]

     
  25. game dreamer says:

    the book is great and i wonder when will the rest of book come out?

  26. VSheyanov says:

    THanks for the book!
    When the other part will come out?
    Thanks!

  27. Get your top ten today…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  28. [...] donc de l’arrivée du second (ok, c’était en mars) pour vous parler du livre WCYDOWB? de Thibault Imbert, l’auteur de Pratique d’ActionScript [...]

     
  29. is fibromyalgia real…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  30. Ihsan says:

    Hi,
    A very brave attempt with very good intentions! If you would not offend, I want to point out that 1 kilo bytes are not 10^3 = 1000 bytes but rather a number very close to it which is 2^10 = 1024 bytes. Because of this closeness amounts of bytes are considered to be named like kilo, mega giga etc. each time expanding with the factor of 2^10. 1KB = 1024 bytes, 1MB = 1024 x 1024 bytes. Thanks for your efforts and patience.

  31. download Opera mini…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  32. Konstantin says:

    I don’t get it, why is there a frog on the book cover?
    I always meant to ask you that.

  33. Wikipedia References…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  34. next chapter says:

    When are the next chapters coming out?

  35. next chapter says:

    next chapter?

  36. Thibault Imbert says:

    Hi guys,

    I have been very busy lately and could not work on the book. I hope I will be able to get back on it soon.

    Thibault

  37. Poco says:

    Any news about the next chapter?

  38. Polaco says:

    I just have found this book by browsing at the site randomly. This chapters are soo enlighteners and enjoyable, thanks a lot Thibault.

  39. vkpm club says:

    vkpm club…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  40. get great graphics here…

    [...]Writing a new book : What can you do with bytes ? – ByteArray.org[...]…

     
  41. sateesh says:

    Any update on the next chapters? Can’t wait to see the rest

  42. Sateesh says:

    I love the flash ecosystem and actionscript very much, needless to say its exiciting. I would like to learn the low-level corner of actionscript. Could you please update the other chapters of “What can you do with bytes” in your mean time, if possible. Again, Thank you very much Thibault.

Leave a Reply

Open Sort Options

Sort comments by:
  • * Applied after refresh

ByteArray.org
Fun with code since 2006.