# 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:** 11\
**Page:** 2

<div class="post-metadata">

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

</div>

Hi @Sans_On,

Good morning from Canada!

Try:

```ruby
use_synth :piano
3.times do
  play_chord [:d4, :d5]
  sleep 0.25
end

```

See what’s different? Programming can be hard. Computers are picky. You must pay attention. Don’t give up!

---

<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 22, 2021, 12:55pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/22 "2021-02-22T12:55:28Z")

</div>

Thank you. Can be used.

---

<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 22, 2021, 1:23pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/23 "2021-02-22T13:23:57Z")

</div>

Please teach me to fix it.  
@d0lfyn piano  
use\_synth :piano  
3.times do  
play\_chord [:d4, :d5]  
sleep 0.25  
play\_chord( :D5, :major)  
sleep 0.5  
play\_chord( :D5, :major)  
sleep 0.25

play\_chord( :A, :major)  
sleep 0.5  
play\_chord( :A, :major)  
sleep 0.5

play\_chord( :G, :major)  
sleep 0.5  
play\_chord( :G, :major)  
sleep 0.5

play\_chord( :A, :major)  
sleep 1  
end

#Faster Piano  
8.times do  
play\_chord( :G, :major)  
sleep 0.25  
end

8.times do  
play\_chord( :A, :major)  
sleep 0.25  
end

play\_chord( :D5, :major)  
end

---

<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 22, 2021, 3:12pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/24 "2021-02-22T15:12:59Z")

</div>

Hi,

In coding you have to take care of the syntax, a space can be enough to break the script.  
So i just indicate the good syntax for the begining then you will have to write yourself the whole code, it’s how you can learn by do it yourself  
So

```ruby
use_synth :piano
3.times do
  play_chord [:d4,:d5]
  sleep 0.25
  play_chord chord(:D5, :major)
  sleep 0.5
end

```

You have missed the `chord` instruction and you have added a wrong space before the root note `:D5`.  
Good luck

---

<div class="post-metadata">

**Author:** ![d0lfyn](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/d0lfyn/32/2254_2.png) [@d0lfyn](https://in-thread.sonic-pi.net/u/d0lfyn)\
**Post date:** [February 22, 2021, 3:53pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/25 "2021-02-22T15:53:19Z")

</div>

You’re welcome! You can learn a lot from the kind people here if you are courteous. You should also read the tutorial first. People can be busy.

I will run your program and show you how to fix the errors one by one.

First:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/d/dfeac65fde1da4e6bf1413a62188f28e65f7961f.png)

This means there is an extra end on line 36. Let’s take it out.

![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/6/6d9d4fa42550b0f71e08ea48697d80cc833c3094.png)

Next:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/a/a3c5c26dbb8d608e6603941ede6b207aca8a72b2.png)

This means on line 5, you’re using `play_chord` wrong. You’re very close.

Let’s look at the documentation for the `play_chord` function. Go to Help \> Lang, and look for `play_chord`.

![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/d/d78c42be423c6f5919a36da1de98acbf7d8cd3d9.png)

If you look at example 3, you’ll find what you’re missing. (@nlb pointed this out too, so make sure to thank them!)

![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/2X/0/037ed8b2ff9c78a461355379a44da5285764cd74.png)

Let’s try.

```ruby
use_synth :piano
3.times do
  play_chord [:d4, :d5]
  sleep 0.25
  play_chord chord(:D5, :major)
  sleep 0.5
  play_chord chord(:D5, :major)
  sleep 0.25
  
  play_chord chord(:A, :major)
  sleep 0.5
  play_chord chord(:A, :major)
  sleep 0.5
  
  play_chord chord(:G, :major)
  sleep 0.5
  play_chord chord(:G, :major)
  sleep 0.5
  
  play_chord chord(:A, :major)
  sleep 1
end

#Faster Piano
8.times do
  play_chord chord(:G, :major)
  sleep 0.25
end

8.times do
  play_chord chord(:A, :major)
  sleep 0.25
end

play_chord chord(:D5, :major)

```

This works because `chord(:D5, major)` gives you `[74, 78, 81]`.

There’s your I-V-IV-V, IV-V-I.

---

<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 22, 2021, 11:15pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/26 "2021-02-22T23:15:45Z")

</div>

Thank you very much… I’ll try it again.  
@nlb  
@d0lfyn

---

<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 23, 2021, 12:30pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/27 "2021-02-23T12:30:51Z")

</div>

how to fix  
#Faster Bass  
8.time do  
play :G2, release: 0.25 amp: 0.5  
sleep 0.25  
end

8.time do  
play :A2, release: 0.25 amp: 0.5  
sleep 0.25  
end

play[:D2, amp: 0.5]  
end

[Runtime Error: [buffer 0, line 830] - SyntaxError  
Thread death!  
workspace\_zero:71: syntax error, unexpected tIDENTIFIER, expecting keyword\_end  
play :G2, release: 0.25 amp: 0.5  
^~~  
workspace\_zero:73: syntax error, unexpected keyword\_end, expecting end-of-input  
end  
^~~  
] @d0lfyn

---

<div class="post-metadata">

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

</div>

Again, computers are picky. You must pay attention. Let’s start from the top:

1. It’s `8.times` not `8.time`
2. Each “argument” for a function like `play` needs a comma. See what’s different here? `play :G2, release: 0.25, amp: 0.5`
3. `play[:D2, amp: 0.5]` is not how you use `play`. Let’s look at the documentation for `play` in Help \> Lang \> play. Example 3 looks like this: `play 62, pan: -1, release: 3`. You should follow that. `play :D2, amp: 0.5`
4. You have an extra `end` at the end of your code. Let’s remove it.

If you fix everything, you will get this. (Try to figure it out before you look at the answer.)

```ruby
#Faster Bass
8.times do
  play :G2, release: 0.25, amp: 0.5
  sleep 0.25
end

8.times do
  play :A2, release: 0.25, amp: 0.5
  sleep 0.25
end

play :D2, amp: 0.5

```

---

<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 23, 2021, 5:22pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/29 "2021-02-23T17:22:30Z")

</div>

hello,

you have to remember that an `end` is always with a `do` as the do and the end creates a block. Inside this block you can write all the code you want to be as example repeated.  
For the latest line, you don’t need a block as the instruction is used only once. So no do neither end.  
Follow the tutorials, you will learn very fast. believe me.  
good luck

---

<div class="post-metadata">

**Author:** ![d0lfyn](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/d0lfyn/32/2254_2.png) [@d0lfyn](https://in-thread.sonic-pi.net/u/d0lfyn)\
**Post date:** [February 23, 2021, 5:31pm UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/30 "2021-02-23T17:31:02Z")

</div>

> [@nlb](#):
>
> you have to remember that an `end` is always with a `do` as the do and the end creates a block

The only times when this is _not_ true is when you are using `if` and `for`. For example:

```ruby
for i in 0..2
  if i.even?
    puts i.to_s + " is even"
  end
end

```

> [@nlb](#):
>
> Follow the tutorials, you will learn very fast. believe me.

I agree! If you really do want to learn to use Sonic Pi, you will have to do some work.

Good luck!

---

<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 24, 2021, 9:19am UTC](https://in-thread.sonic-pi.net/t/how-to-new-file/5164/31 "2021-02-24T09:19:25Z")

</div>

Yep. Absolutely ! I was too much focused on the times case

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