# How to new file

**URL:** <https://in-thread.sonic-pi.net/t/how-to-new-file/5164>\
**Category:** Support, Help & Resources\
**Created:** [February 21, 2021, 5:53am UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164 "2021-02-21T05:53:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 5:53am UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/1 "2021-02-21T05:53:15Z")

</div>

Hi, my name is NaMo.  
I’m 14.  
I live in Thailand.  
I just found out.  
I’m a new user.  
I want to know how to create a new file.

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 21, 2021, 11:49am UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/2 "2021-02-21T11:49:00Z")

</div>

Hi @Sans_On  
Welcome into our community !  
So to play two :C notes, just type into a buffer

```ruby
play :c4
sleep 1
play :c5
sleep 1

```

Then press the run button.  
You can save your code into a file via save button. But actually if you close sonic pi then reopen, you will see your code into the buffer used. so no need to save it.  
I encourage you to read the tutorials. They are done for starters !  
Good coding !

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 12:54pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/3 "2021-02-21T12:54:07Z")

</div>

![Screenshot_2021-02-21_06-54-24](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/1/19cb76109570da12090a7b33e74b0c183c59c7bc.png)  
How to fix it

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 21, 2021, 1:11pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/4 "2021-02-21T13:11:17Z")

</div>

To learn how to use the `play_chord` instruction, hit the F1 key to access to the help and you will learn how to use.

```ruby
play_chord [:c4, :e4, :g4]
sleep 1
play chord(:c4,:major)

```

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 1:23pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/5 "2021-02-21T13:23:33Z")

</div>

![Screenshot_2021-02-21_07-23-03](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/9/9913eab9b5d18304153737142d760fef50672544.png)

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 21, 2021, 1:27pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/6 "2021-02-21T13:27:46Z")

</div>

show me line 4 🙂  
You have to respect the syntax i gave you. So use [ instead of (

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 1:33pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/7 "2021-02-21T13:33:13Z")

</div>

![25](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/f/f3976a3415de84445135fc59d516fb88725f8bd4.png)

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 1:39pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/8 "2021-02-21T13:39:11Z")

</div>

I’ve been trying to fix it for a long time.

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [February 21, 2021, 1:39pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/9 "2021-02-21T13:39:19Z")

</div>

Hey NaMo, welcome! 😀

As you can see, when writing code, the interpreters than run the code are often quite strict about the structure that that code is written in!

In your most recent screenshot above, it’s complaining because it is expecting to see the word `end` that matches up with the `do` in the `3.times do`. (This `do`…`end` and the code inside it is all known as a block - and the block has to have matching `do` and `end` words to properly wrap the code inside it 🙂

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [February 21, 2021, 1:43pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/10 "2021-02-21T13:43:12Z")

</div>

Once you have properly closed the block with an `end`, the next thing to adjust is the way you call the `play_chord` function. Like @nlb says, you can hit a shortcut in the editor to find help about the function. If you place the text cursor inside the `play_chord` word, and hit F1, or `C-i` (Control + i), the help panel will open with documentation about the `play_chord` function. There, it will describe how to use the function, and will show examples of it being used as well, at the bottom…

There are also clues about your original problem in the original error message that pops up. It says: “play\_chord expects a list of notes such as [70, 75, 82], got :Db5”

What that is saying is: to tell `play_chord` what to play, it needs a _list_ of notes. In Sonic Pi, this is given either by an array (numbers surrounded by square brackets: `[1, 2, 3]`) or a ring (numbers passed to the `ring` function: `(ring 1, 2, 3)`.

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 1:46pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/11 "2021-02-21T13:46:09Z")

</div>

![Screenshot_2021-02-21_07-45-13](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/a/a8ce9b919dbf8ed55e0caf1e690ffef01a6e63d5.png)

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 1:48pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/12 "2021-02-21T13:48:51Z")

</div>

ok i will try as you said

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [February 21, 2021, 2:01pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/13 "2021-02-21T14:01:52Z")

</div>

It’s also worth knowing that when passing the list to the `play_chord` function (and when trying to pass arrays to other functions as well) that we need to be careful about how we do it: there is a big difference between this:

```ruby
play_chord[:d4, :d5]

```

and this:

```ruby
play_chord [:d4, :d5]

```

The first way will not work, because Sonic Pi thinks that you are using the ‘[’ and ‘]’ to get a value _out_ of an array - but we are trying to pass an array to a function! (The space in between in the second example here helps to tell Sonic Pi that `play_chord` is a function and we are passing an array `[:d4, :d5]` to it as a parameter.

Hopefully this makes some kind of sense - if not, don’t worry too much. It’s helpful to read the Tutorial as we have said above - it’s written in hopefully a very easy style. Things like functions, lists etc are all talked about there.

Have a go reading through some of it if you can - pasting examples into the editor as you go. There are also plenty of documents about the various functions in Sonic Pi in the Lang section of the help panel - very useful to see how the various functions are used.

All the best with your Sonic Pi journey - if you have more questions while you keep exploring and trying things and can’t find any answers, go ahead and ask.

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 2:10pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/14 "2021-02-21T14:10:30Z")

</div>

![Screenshot_2021-02-21_08-09-13](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/7/7e8b7eb9a70639459fbd6cf39cbd6f38e4cbeb17.png)

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 2:11pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/15 "2021-02-21T14:11:48Z")

</div>

i’m go to sleeping good night  
see you later

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 2:14pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/16 "2021-02-21T14:14:22Z")

</div>

Or do I have to delete. And then reloading?

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 21, 2021, 2:14pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/17 "2021-02-21T14:14:28Z")

</div>

well @Sans_On  
instead of screenshooting, copy paste your code between three ```.  
By the way, we are happy to help but give us and give you chances to get help.  
By the way, a little “thank you” is always appreciated 🙂

---

<div class="post-metadata">

**Author:** ![Sans\_On](https://avatars.discourse-cdn.com/v4/letter/s/b3f665/32.png) [@Sans\_On](https://in-thread.sonic-pi.net/u/Sans_On)\
**Post date:** [February 21, 2021, 2:17pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/18 "2021-02-21T14:17:11Z")

</div>

The fact that you look at the pictures may speed up fixing the problem.

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [February 21, 2021, 2:18pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/19 "2021-02-21T14:18:43Z")

</div>

Not quite sure what you mean by delete and reload.

Nlb is right that it is much better to copy the code here for us rather than an image. That way we can easily copy it and paste it into our own Sonic Pi app to test, rather than maybe typing it out if we can’t see the error immediately.  
Note: If you copy your code here, put a blank line before and after your code, and then put three backticks ``` each on those blank lines, the code will be formatted in pretty highlighting to make it nicer to read 🙂  
Screenshots are really only helpful for the error messages - for the code, pasting here in formatted text is easier to read…

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 21, 2021, 2:19pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/20 "2021-02-21T14:19:45Z")

</div>

not at all  
with code we can copy / paste your whole code and exchange seriously in order to give you the best help we can.  
good night even if for me in France this is afternoon 😉

[Next page](https://in-thread.sonic-pi.net/t/how-to-new-file/5164.md?page=2)
