How to new file

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.

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

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 !


How to fix it

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.

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

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

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

Hey NaMo, welcome! :grinning:

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 doend 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 :slight_smile:

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).

ok i will try as you said

1 Like

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:

play_chord[:d4, :d5]

and this:

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.

i’m go to sleeping good night
see you later

Or do I have to delete. And then reloading?

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 :slight_smile:

1 Like

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

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 :slight_smile:
Screenshots are really only helpful for the error messages - for the code, pasting here in formatted text is easier to read…

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 :wink: