GithubHelp home page GithubHelp logo

flujoo / gm Goto Github PK

View Code? Open in Web Editor NEW
197.0 4.0 6.0 9.14 MB

R Package for Music Creation

Home Page: https://flujoo.github.io/gm/

License: Other

R 100.00%
r musicxml music-programming algorithmic-composition

gm's Introduction

gm logo

Create music with R.

Example

library(gm)

music <- 
  Music() +
  Meter(4, 4) +
  Line(c("C5", "D5", "E5", "F5"))
  
show(music)

Installation

Install gm:

install.packages("gm")

# Or install the development version from GitHub
pak::pak("flujoo/gm")

Install MuseScore. MuseScore is open source and free notation software.

More

See vignette("gm") for a complete guide to gm.

gm's People

Contributors

flujoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gm's Issues

other instruments ?

Thanks for this package, I had fun with it all evening.

Is it possible to hear another instrument than the piano ?
I have looked at all function arguments but haven't found a way.

If it's not possible as is, could you indicate me where this is set in the code so I can find a way to hack it for myself ?

NA and NA_integer_ problem

First of all, thanks a lot for this package, it is a lot of fun to work with R + music!

When turning a dataframe into a melody I noticed that there is an issue with the NAs.

This is an example which recreates the error:

library(gm)

df <- data.frame(num = 40:50)
df[df == 45] <- NA

m <- Music() + Meter(4, 4) +
Line(pitches = as.list(df$num),
durations = as.list(rep("quarter", nrow(df))))

I get this error message:
Each item of pitches must be a single logical NA, or be a character or numeric vector containing pitch notations and MIDI note numbers.

  • pitches[[6]][1] is NA_integer_.

However, when I run through the list and replace all the NA_integer_ with NA, it works - so it has something to do with the different types of NA_integer_, NA_character_ etc. and the normal NA.

m <- Music() + Meter(4, 4) +
Line(pitches = lapply(as.list(df$num),
function(x) if(is.na(x)) NA else x),
durations = as.list(rep("quarter", nrow(df))))

This probably does not have a high priority, but in case that it is easy to fix, maybe it would be great to interpret NA_integer_ also as pauses.

Thanks again, awesome package!

Cannot find MuseScore on Windows even with “.Renviron” altered

Hi there, It seems a nice work that you have done! I´m trying to use it on a Windows machine. I did follow the tutorial and tried several forms, but R cannot find MuseScore (I used the program normally after installation).

Error: MuseScore must be installed to convert Music object to score or audio file.

I edited the “.Renviron” as suggested. It was the default path anyway "C:\Program Files\MuseScore 3\bin".

I tried a) "C:\Program Files\MuseScore 3\bin",
b) "C:/Program Files/MuseScore 3/bin/" and
c) "C:%\Program Files%\MuseScore%3%\bin%"

Any suggestion?
Thanks!

R-Music inclusion

Thanks for your message via the R-Music blog, this package is pretty cool! How would you like me to include it in R-Music, are you willing to 'transfer the repository to our GitHub organization https://r-music.rbind.io/ and/or write a blog post about it (for the R-Music blog)?

show in LaTeX/pdf

It would be great if show function could also include an option for PDF/LateX, which is often knit from .Rmd.
The export function is one workaround but these graphic files (pdf, png) define full page around the excerpt and cannot be easily embedded into Rmd without cropping the extra space. I really like the library and would like to incorporate to my teaching materials about music and science.

show(m, to = c("audio","score")) results in Error: rsession-arm64: NegativeOrZeroImageSize `' @ error/image.c/CloneImage/795

I'm trying to run show(m, to = c("audio","score")) from the Quick Example but it gives the error Error: rsession-arm64: NegativeOrZeroImageSize ' @ error/image.c/CloneImage/795`. Are there any suggestions you can kindly recommend for getting past this error?

What I've Tried Thus Far

  1. I searched for this error and it's related to the magick library. So I then tested it to make sure it's working and it does.

  2. I read that .Renviron needs MUSESCORE_PATH=/Applications/MuseScore 4.app and usethis::edit_r_environ() to verify that it's there.

  3. I tried running `show(m, to = c("audio")) and in the Rstudio view is just renders a media ui that's not playable, i.e. you can not click play to hear the "C5".

  4. I tried running show(m) and it results in the same error mentioned in the title.

  5. I checked that MuseScore 4 is working by exporting a score in svg.

  6. I tried checking that all the dependencies are installed with tools::package_dependencies("gm").

System Details
Computer: Macbook Air
Memory: 8GB
Chip: Apple M1
Sonoma 14.2.1
git version 2.39.3 (Apple Git-146)
Homebrew 4.2.16
/opt/brew/opt/pkg-config (appears installed here)
Rstudio: Version 2023.03.1+446 (2023.03.1+446)
R version 4.3.3
gm version 1.0.2

Console Details
`

library(gm)

m <- Music()

m <- m +

  • Meter(4,4) +
  • Line(pitches = list("C5"), durations = list("whole"))

show(m, to = c("audio","score"))
Error: rsession-arm64: NegativeOrZeroImageSize ' @ error/image.c/CloneImage/795

Adding text to a score

I wonder whether it would be possible to add a text label to a score (title, lyric, expression, or label). This could be handy in some cases but there might be other workarounds beyond gm.

"show" works on Windows 11 but gives an error message

I've got MuseScore 3 installed on Windows 11 and installed gm. When I run the first example in the vignette

> library(gm)

Attaching package: ‘gm’

The following object is masked from ‘package:methods’:

    show

> m <- Music()
> m <- m +
+     # add a 4/4 time signature
+     Meter(4, 4) +
+     # add a musical line of a C5 whole note
+     Line(pitches = list("C5"), durations = list("whole"))
> m
Music

Line 1

* as part 1 staff 1 voice 1
* of length 1
* of pitch C5
* of duration 4

Meter 4/4 
> show(m, to = c("score", "audio"))
m_crashReporterWChar: C:/PROGRA~1/MUSESC~2/bin/MuseScore3-crash-reporter.exem_crashReporterWChar: C:/PROGRA~1/MUSESC~2/bin/MuseScore3-crash-reporter.exe
>

the score displays correctly and the audio file is playable, but it appears to be calling a crash reporter. Is this a problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.