# Include functions in multiple projects

**URL:** <https://in-thread.sonic-pi.net/t/include-functions-in-multiple-projects/1683>\
**Category:** Support, Help & Resources\
**Created:** [November 11, 2018, 2:59pm UTC](https://in-thread.sonic-pi.net/t/include-functions-in-multiple-projects/1683 "2018-11-11T14:59:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [November 11, 2018, 3:46pm UTC](https://in-thread.sonic-pi.net/t/include-functions-in-multiple-projects/1683/2 "2018-11-11T15:46:23Z")

</div>

One way is to use

```ruby
run_file [path_to_file]

```

If you want the code to be available for all of your projects the more conveniant way is to add it to your SP startup file. Under Linux mine can be found at:

```ruby
/home/[username]/.sonic-pi/init.rb

```

In my case it contains e. g.:

```ruby
# Sonic Pi init file
# Code in here will be evaluated on launch.

load_snippets("~/.sonic-pi/snippets")

# to referenced e. g. like: 'sample atmos, 0'
define :atmos do
  atmos = "/path/to/some/sample/libraries/"
end

# more libraries

#################################################
# Custom functions ##############################
#################################################

# https://github.com/samaaron/sonic-pi/issues/1691
# modified by mb@mkblog.org
# Use: midi_chord chord(:c4, :major), sustain: 0.2
define :midi_chord do |notes, *args|
  if notes != :r
    notes.each do |note|
      midi note, *args
    end
  else
    play :r
  end
end

```

Hope this helps.

Martin

---

_[View the full topic](https://in-thread.sonic-pi.net/t/include-functions-in-multiple-projects/1683)._
