Csound Csound-dev Csound-tekno Search About

[Csnd] how to get number of samples in a soundfile

Date2020-04-11 15:16
FromStefan Thomas
Subject[Csnd] how to get number of samples in a soundfile
Dear community,
I would like to know if there is a possibility to get easily the number of samples in an audio file.
Of course there is the code I've found in "csound power" by Jim Aikin
giSample ftgen 0,0,0,1,"source_mono.wav",0,0,0 ; sampleLength: 69632.000
instr 1
    ilen tableng giSample
    print ilen
endin
but is there a way which works conveniently with a larger number different sound files?
Thanks for Your help!
Stefan
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-04-11 15:23
FromTarmo Johannes
SubjectRe: [Csnd] how to get number of samples in a soundfile
AttachmentsNone  None  

Date2020-04-12 15:07
FromRichard Knight
SubjectRe: [Csnd] how to get number of samples in a soundfile
 hi- probably best to use filesr rather than sr in case it differs? Ie
 filelen(Sfile)*filesr(Sfile)

 On Sat, 11 Apr 2020 17:23:29 +0300, Tarmo Johannes wrote:
> Hi,
>
> I don't know how exaxt it is but can filelen(Sfile)*sr give the
> result?
>
> tarmo
>
> Sent from Mailspring [4], the best free email app for work
> On Apr 11 2020, at 5:16 pm, Stefan Thomas  wrote:
>
>> Dear community,
>> I would like to know if there is a possibility to get easily the
>> number of samples in an audio file.
>> Of course there is the code I've found in "csound power" by Jim
>> Aikin
>>
>>> giSample ftgen 0,0,0,1,"source_mono.wav",0,0,0 ; sampleLength:
>>> 69632.000
>>>
>>> instr 1
>>> ilen tableng giSample
>>> print ilen
>>> endin
>>
>> but is there a way which works conveniently with a larger number
>> different sound files?
>> Thanks for Your help!
>>
>> Stefan
>> Csound mailing list Csound@listserv.heanet.ie [1]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [2] Send bugs
>> reports to https://github.com/csound/csound/issues [3] Discussions
>> of bugs and features can be posted here
>  Csound mailing list Csound@listserv.heanet.ie [5]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [6] Send bugs reports
> to https://github.com/csound/csound/issues [7] Discussions of bugs 
> and
> features can be posted here
>
> Links:
> ------
> [1]
> 
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/1?redirect=mailto%3ACsound%40listserv.heanet.ie|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [2]
> 
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/2?redirect=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [3]
> 
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/3?redirect=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [4]
> 
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [5] mailto:Csound@listserv.heanet.ie
> [6] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> [7] https://github.com/csound/csound/issues

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-04-13 12:01
FromStefan Thomas
SubjectRe: [Csnd] how to get number of samples in a soundfile
I've been thinking more on a linux command line tool which could do this. Do you know if something like this exists?


Richard Knight <Richard@1bpm.net> schrieb am So., 12. Apr. 2020, 16:07:
 hi- probably best to use filesr rather than sr in case it differs? Ie
 filelen(Sfile)*filesr(Sfile)

 On Sat, 11 Apr 2020 17:23:29 +0300, Tarmo Johannes wrote:
> Hi,
>
> I don't know how exaxt it is but can filelen(Sfile)*sr give the
> result?
>
> tarmo
>
> Sent from Mailspring [4], the best free email app for work
> On Apr 11 2020, at 5:16 pm, Stefan Thomas  wrote:
>
>> Dear community,
>> I would like to know if there is a possibility to get easily the
>> number of samples in an audio file.
>> Of course there is the code I've found in "csound power" by Jim
>> Aikin
>>
>>> giSample ftgen 0,0,0,1,"source_mono.wav",0,0,0 ; sampleLength:
>>> 69632.000
>>>
>>> instr 1
>>> ilen tableng giSample
>>> print ilen
>>> endin
>>
>> but is there a way which works conveniently with a larger number
>> different sound files?
>> Thanks for Your help!
>>
>> Stefan
>> Csound mailing list Csound@listserv.heanet.ie [1]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [2] Send bugs
>> reports to https://github.com/csound/csound/issues [3] Discussions
>> of bugs and features can be posted here
>  Csound mailing list Csound@listserv.heanet.ie [5]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [6] Send bugs reports
> to https://github.com/csound/csound/issues [7] Discussions of bugs
> and
> features can be posted here
>
> Links:
> ------
> [1]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/1?redirect=mailto%3ACsound%40listserv.heanet.ie|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [2]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/2?redirect=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [3]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/3?redirect=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [4]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [5] mailto:Csound@listserv.heanet.ie
> [6] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> [7] https://github.com/csound/csound/issues

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-04-13 12:03
FromRory Walsh
SubjectRe: [Csnd] how to get number of samples in a soundfile
I assume sox will get you all the info you need? 

On Mon, 13 Apr 2020 at 12:02, Stefan Thomas <kontrapunktstefan@gmail.com> wrote:
I've been thinking more on a linux command line tool which could do this. Do you know if something like this exists?


Richard Knight <Richard@1bpm.net> schrieb am So., 12. Apr. 2020, 16:07:
 hi- probably best to use filesr rather than sr in case it differs? Ie
 filelen(Sfile)*filesr(Sfile)

 On Sat, 11 Apr 2020 17:23:29 +0300, Tarmo Johannes wrote:
> Hi,
>
> I don't know how exaxt it is but can filelen(Sfile)*sr give the
> result?
>
> tarmo
>
> Sent from Mailspring [4], the best free email app for work
> On Apr 11 2020, at 5:16 pm, Stefan Thomas  wrote:
>
>> Dear community,
>> I would like to know if there is a possibility to get easily the
>> number of samples in an audio file.
>> Of course there is the code I've found in "csound power" by Jim
>> Aikin
>>
>>> giSample ftgen 0,0,0,1,"source_mono.wav",0,0,0 ; sampleLength:
>>> 69632.000
>>>
>>> instr 1
>>> ilen tableng giSample
>>> print ilen
>>> endin
>>
>> but is there a way which works conveniently with a larger number
>> different sound files?
>> Thanks for Your help!
>>
>> Stefan
>> Csound mailing list Csound@listserv.heanet.ie [1]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [2] Send bugs
>> reports to https://github.com/csound/csound/issues [3] Discussions
>> of bugs and features can be posted here
>  Csound mailing list Csound@listserv.heanet.ie [5]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [6] Send bugs reports
> to https://github.com/csound/csound/issues [7] Discussions of bugs
> and
> features can be posted here
>
> Links:
> ------
> [1]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/1?redirect=mailto%3ACsound%40listserv.heanet.ie|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [2]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/2?redirect=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [3]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/3?redirect=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [4]
>
> https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
> [5] mailto:Csound@listserv.heanet.ie
> [6] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> [7] https://github.com/csound/csound/issues

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-04-13 12:09
FromJohn ff
SubjectRe: [Csnd] how to get number of samples in a soundfile
Sndfile utility info does it too

⁣Sent from TypeApp ​

On Apr 13, 2020, 12:04, at 12:04, Rory Walsh  wrote:
>I assume sox will get you all the info you need?
>
>On Mon, 13 Apr 2020 at 12:02, Stefan Thomas
>
>wrote:
>
>> I've been thinking more on a linux command line tool which could do
>this.
>> Do you know if something like this exists?
>>
>>
>> Richard Knight  schrieb am So., 12. Apr. 2020,
>16:07:
>>
>>>  hi- probably best to use filesr rather than sr in case it differs?
>Ie
>>>  filelen(Sfile)*filesr(Sfile)
>>>
>>>  On Sat, 11 Apr 2020 17:23:29 +0300, Tarmo Johannes wrote:
>>> > Hi,
>>> >
>>> > I don't know how exaxt it is but can filelen(Sfile)*sr give the
>>> > result?
>>> >
>>> > tarmo
>>> >
>>> > Sent from Mailspring [4], the best free email app for work
>>> > On Apr 11 2020, at 5:16 pm, Stefan Thomas  wrote:
>>> >
>>> >> Dear community,
>>> >> I would like to know if there is a possibility to get easily the
>>> >> number of samples in an audio file.
>>> >> Of course there is the code I've found in "csound power" by Jim
>>> >> Aikin
>>> >>
>>> >>> giSample ftgen 0,0,0,1,"source_mono.wav",0,0,0 ; sampleLength:
>>> >>> 69632.000
>>> >>>
>>> >>> instr 1
>>> >>> ilen tableng giSample
>>> >>> print ilen
>>> >>> endin
>>> >>
>>> >> but is there a way which works conveniently with a larger number
>>> >> different sound files?
>>> >> Thanks for Your help!
>>> >>
>>> >> Stefan
>>> >> Csound mailing list Csound@listserv.heanet.ie [1]
>>> >> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [2] Send bugs
>>> >> reports to https://github.com/csound/csound/issues [3]
>Discussions
>>> >> of bugs and features can be posted here
>>> >  Csound mailing list Csound@listserv.heanet.ie [5]
>>> > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND [6] Send bugs
>reports
>>> > to https://github.com/csound/csound/issues [7] Discussions of bugs
>>> > and
>>> > features can be posted here
>>> >
>>> > Links:
>>> > ------
>>> > [1]
>>> >
>>> >
>>>
>https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/1?redirect=mailto%3ACsound%40listserv.heanet.ie|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
>>>
>
>>> > [2]
>>> >
>>> >
>>>
>https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/2?redirect=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
>>>
>
>>> > [3]
>>> >
>>> >
>>>
>https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/3?redirect=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
>>>
>
>>> > [4]
>>> >
>>> >
>>>
>https://link.getmailspring.com/link/21AA4F01-FBE7-4F25-A3FC-3D33590EA30F@getmailspring.com/0?redirect=https%3A%2F%2Fgetmailspring.com%2F|+|amp|+|recipient=Q1NPVU5EQGxpc3RzZXJ2LmhlYW5ldC5pZQ%3D%3D
>>>
>
>>> > [5] mailto:Csound@listserv.heanet.ie
>>> > [6] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>> > [7] https://github.com/csound/csound/issues
>>>
>>> Csound mailing list
>>> Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>>> Send bugs reports to
>>>         https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and
>features
>> can be posted here
>
>Csound mailing list
>Csound@listserv.heanet.ie
>https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>Send bugs reports to
>        https://github.com/csound/csound/issues
>Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here