# Where to put loadBytes()?

**URL:** <https://discourse.processing.org/t/where-to-put-loadbytes/13818>\
**Category:** Beginners\
**Created:** [September 5, 2019, 6:23am UTC](https://discourse.processing.org/t/where-to-put-loadbytes/13818 "2019-09-05T06:23:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [September 5, 2019, 6:23am UTC](https://discourse.processing.org/t/where-to-put-loadbytes/13818/1 "2019-09-05T06:23:08Z")

</div>

Hi

Can anyone confirm … can loadBytes() only be used in preload() ?  
If I try in setup() or anywhere else (e.g. in a new class) it doesn’t work.

```auto

let data;

function preload() {
  data = loadBytes('assets/kick.wav');
}

function setup() {
//putting loadBytes() here doesn't seem to work?
//data = loadBytes('assets/kick.wav');

  for (let i = 0; i < 5; i++) {
    console.log("bytes[" + i + "] = " + data.bytes[i]) ;
  }
}

function draw() {

}

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 5, 2019, 7:40am UTC](https://discourse.processing.org/t/where-to-put-loadbytes/13818/2 "2019-09-05T07:40:04Z")

</div>

wrong timing: need to wait…  
[https://editor.p5js.org/kll/sketches/X0KSkVzeg](https://editor.p5js.org/kll/sketches/X0KSkVzeg)  
works

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [September 5, 2019, 10:31am UTC](https://discourse.processing.org/t/where-to-put-loadbytes/13818/3 "2019-09-05T10:31:13Z")

</div>

@kll  
Many thanks again … will use the callbacks!
